New Posts New Posts RSS Feed: How to get all errors from EntityManager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

How to get all errors from EntityManager

 Post Reply Post Reply
Author
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Topic: How to get all errors from EntityManager
    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.
 


Edited by katit - 04-Feb-2013 at 5:13pm
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post 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);



Edited by sbelini - 05-Feb-2013 at 12:38pm
Back to Top
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Posted: 06-Feb-2013 at 10:35am
Thanks! This is what I needed
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down