Does WPF break an Entity Framework ObjectContext?
Posted
by David Veeneman
on Stack Overflow
See other posts from Stack Overflow
or by David Veeneman
Published on 2010-03-12T15:08:19Z
Indexed on
2010/03/12
18:17 UTC
Read the original article
Hit count: 392
I am getting started with Entity Framework 4, and I am getting ready to write a WPF demo app to learn EF4 better. My LINQ queries return IQueryable<T>
, and I know I can drop those into an 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 that point, I can set the appropriate property on my view model to the observable collection, and I will get WPF data binding between the view and the view model property.
Here is my question: Do I break the ObjectContext when I move my foo list to the observable collection? Or put another way, assuming I am otherwise handling my ObjectContext properly, will EF4 properly update the model (and the database)?
The reason why I ask is this: NHibernate tracks objects at the collection level. If I move an NHibernate IList<T>
to an observable collection, it breaks NHibernate's change tracking mechanism. That means I have to do some very complicated object wrapping to get NHibernate to work with WPF. I am looking at EF4 as a way to dispense with all that.
So, to get EF4 working with WPF, is it as simple as dropping my IQueryable<T>
results into an ObservableCollection<T>
. Does that preserve change-tracking on my EDM entity objects? Thanks for your help.
© Stack Overflow or respective owner