Click here to Skip to main content
13,196,286 members (47,273 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I have this strange problem:

You have a database with these rows:
Table: Letter

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

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

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 18-Sep-12 22:56pm
Updated 18-Sep-12 23:51pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Js. Urb. 19-Sep-12 5:41am

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.

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171019.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100