Entity Framework POCO - Refresh a natvigation property?

I think you misunderstood MergeOption. OverwriteChanges . By default, anytime the ObjectContext performs a query, if any of the returned objects already exist in the cache the newly returned copies of those objects are ignored.

Please note that it all happens based on the EntityKeys . Basically the EntityKeys of the objects returned from a query are checked, and if an object with the same EntityKey (in the same EntitySet, in your case Lectures ) already exists in the cache, the existing object is left untouched. However, if you enable OverwriteChanges then it will Replace the current values of existing entities with values coming from the database, even if the in-memory entity has been edited.

As you can see you are adding a Lecture to the student that is totally new to Student and it will not be overwritten since its EntityKey is different than the ones that coming from database as per your LoadProperty() call. One solution would be to just simply clear all the Lectures from your student object just before LoadProperty().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions