Does WPF deploy ObjectContext Framework Entity Framework?

I am getting started with Entity Framework 4 and am ready to write a WPF demo application to learn more about EF4. My LINQ queries are returning IQueryable<T>

, and I know I can cast them in ObservableCollection<T>

with the following code:

IQueryable<Foo> fooList = from f in Foo orderby f.Title select f;
var observableFooList = new ObservableCollection<Foo>(fooList);

      

At this point, I can set the corresponding property in my view model to an observable collection and I will have WPF data binding between the view and the view property.

Here's my question: Does the ObjectContext break when moving the list foo into an observable collection? Or otherwise, assuming I'm otherwise handling my ObjectContext correctly, will EF4 update the model (and database) correctly?

The reason I'm asking is this: NHibernate keeps track of objects at the collection level. If I move NHibernate IList<T>

to an observable collection it breaks NHibernate's change tracking mechanism. This means that I need to do a very complex object wrapper to get NHibernate to work with WPF. I see EF4 as a way around all of this.

So, to get EF4 working with WPF, it's as easy as dumping my results IQueryable<T>

into ObservableCollection<T>

. Does this keep track of changes on the EDM entity objects? Thanks for your help.

+1


a source to share


1 answer


You need to keep the ObservableCollection in sync with the ObjectContext. The BookLibrary WPF Application Framework (WAF) sample shows how this can be done . Search for EntityObservableCollection.



+3


a source







All Articles