Print Page | Close Window

How to get all errors from EntityManager

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3975
Printed Date: 07-Sep-2025 at 6:26am


Topic: How to get all errors from EntityManager
Posted By: katit
Subject: How to get all errors from EntityManager
Date Posted: 04-Feb-2013 at 5:00pm
Currently I'm using following pattern to get verification errors out of CurrentItem<T>
 
public List<string> ValidationErrors
        {
            get
            {
                var validationErrors = new List<string>();
                if (this.CurrentItem != null)
                {
                    validationErrors.AddRange((from errors in this.CurrentItem.EntityAspect.ValidationErrors select errors.Message).ToList());
                }
                return validationErrors;
            }
        }
 
I want to make sure child items also covered, in case I do header/detail manipulation I want to see errors from "Order" and "OrderLine"
 
EDITED:
 
I know how to easily get all entities within manager but it might contain other records I don't care about. I really want to verify just "Graph" So, ideally I want to iterate only main item and it's childs/subchilds.
 



Replies:
Posted By: sbelini
Date Posted: 05-Feb-2013 at 12:37pm
Hi katit,

You might want to get the entity graph. i.e.:


var rootEntities = new List<Entity>();
rootEntities.Add(someEmployees);

var spans = new List<EntitySpan>();

EntitySpan span = new EntitySpan(typeof(Employee),
    EntityRelations.FK_Order_Employee,
    EntityRelations.FK_OrderDetail_Order,
    EntityRelations.FK_OrderDetail_Product);

spans.Add(span);

var entityGraph = manager.FindEntityGraph(rootEntities, spans, EntityState.AllButDetached);



Posted By: katit
Date Posted: 06-Feb-2013 at 10:35am
Thanks! This is what I needed



Print Page | Close Window