Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Entity Framework question
Message
From
05/11/2009 13:58:31
 
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01433374
Message ID:
01433387
Views:
65
>I'm sure the answer to this must be simple but I'm still finding my way around the Entity Framework so....
>
>I load an EntityObject (User) together with a child EntityCollection (Roles). Subsequently I programatically remove one or more items from the collection.
>
>Given a reference to the EntityObject how do I reload the original EntityCollection?
>
>TIA,
>Viv

Hmm, I've never even built an EF model, so I'm just asking a curious question here... If, when you deleted the Item from the child collection, you were working against the collection that (I assume) is a linked property off of the parent Entity, why would it be necessary to "reload" the parent (and thereby the child collection, right)?

Thinking about this kind of architecture from a classic object oriented paradigm, it seems like the parent's collection of child items would just always be up to date with respect to the in-memory state of the data model, as long as your work against THAT collection, not some other un-linked colelction of the same child objects.

Notwithstanding the above (possibly stupid assumption), how did you initially populate the parent (and related child records)? Is there a call like User.Load(UserID)? If so, you'd need to be sure to "push" the delete on the child collection back to the real back-end data, then call the User.Load() method to pull back a fresh version of the parent and child records (after delete).

I'll be curious to find out how this all works. I've only used LinqToSql so far, so EF seems like a BIG MONSTER to me. Maybe it's not.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform