Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Entity Framework - Entity Collection Refresh
Message
From
12/05/2010 15:26:33
 
 
To
12/05/2010 14:45:33
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01464069
Message ID:
01464340
Views:
38
>>>>>I have a back end data store that is receiving frequent updates from another process. (Currently SQL Express 2005 but I don't want to tie myself to that.)
>>>>>
>>>>>I have one table of groups and another that is children of that group, some of the children are periodically moved from one group to another and sometimes new children are added.
>>>>>
>>>>>When I do a:
>>>>>
>>>>>MyContext.Refresh(RefreshMode.StoreWins, group.children);
>>>>>
>>>>>The child collection does not reflect any of the added children. Is there a way to get these child collections to fully refresh?
>>>>
>>>>OK... I got a little further:
>>>>
>>>>group.children.Load(MergeOption.OverwriteChanges);
>>>>
>>>>Does cause the children to refresh. Unfortunately... when it comes to the AssociationChanged Event:
>>>>
>>>>"Events may be suppressed during bulk operations, such as Load, Attach, and Clear."
>>>>
>>>>So I'm still searching for a way to update anything else that might need updating and I'm unsure how it will behave in WPF. (I'll have to test that.)
>>>
>>>Talking to myself again <g>
>>>
>>>The AssociationChanged event was getting called and it does work. My event hook up wasn't getting called.
>>
>>Glad it's working. I wondered whether "Events may be suppressed during bulk operations, such as Load, Attach, and Clear."
>>should be taken literally:"Events may be suppressed during bulk operations, such as Load, Attach, and Clear."
>> - i.e. implying the event would still fire *after* the load ?
>
>Ya... brain dead moment on my part. Wrote the code to hook up the events but I never called it. LOL Figured it out instantly when I saw that WPF was getting the events.
>
>Keeping local data in sync with the data store was one area that VFP really handled a lot better than .NET. Seems like I'm constatnly having fun with refreshes in .NET, but I learned a few tricks from this one that may help me out in the future.
>
>Discovering that I can call Load on an entity set that is already loaded (silly me assumed that once it was loaded it was loaded) may help a lot with my refresh woes. From another discusion it sounds like this can also work with execute, but I haven't tested that yet.

I must admit to struggling somewhat with the Entity Framework on occasion. The changes in .NET 4 look useful but I haven't had time to play with them yet......

My current favourite toy is the .NET 4 Tuple class !
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform