Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have this strange problem:

You have a database with these rows:
HTML
Table: Letter

Id=1,Name="A"
Id=1,Name="B"
Id=1,Name="C"

Now you make the query
C#
var q= (from l in context.Letter where l="A" select l);
g.Load();

Now in context.Local yo have only one row (the first one)

If you go to database and remove or delete or add files, the Local refresh accordingly (you must use Load() and Refresh() between changes).

But in this case it does not work, see it:

You go to database and change "A" to "B" and repeat the query
C#
g.Load();

The entity changes his value to "B" so it must been removed from Local but it stills alive in Local (count==1) when the local must have 0 elements (count==0)

Any idea?
Posted
Updated 18-Sep-12 23:51pm
v3

1 solution

 
Share this answer
 
Comments
Js. Urb. 19-Sep-12 5:41am    
Hello,

I appreciate your help, but i am already using Refresh(), the problem is that in the scenario i expose Refresh()/Load() does not work, you can try it if you wish.

Thanks,
Zoltán Zörgő 19-Sep-12 6:51am    
With load, you just force execution of the deferred query. But with refresh you force the context to reload data. Have you really tried that also? Since I had the same problem, and calling refresh on the context solved it.
Js. Urb. 19-Sep-12 7:21am    
It works in the scenarios i talk about (add, delete, edit,...) but try the case i talk above, one Entity that is changed after initial execution and does not mismatch must dissapear but is not the case, keep in mind that i am using CodeFirst casting DbContext to ObjectContext to use Refresh()
Js. Urb. 19-Sep-12 10:07am    
I think that's because DBQuery encapsulates a ObjectQuey with MergeOption set to AppendOnly and it does not seem possible to set to OverwriteChanges...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900