New Posts New Posts RSS Feed: Query Strategy Not working??
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Query Strategy Not working??

 Post Reply Post Reply
Author
jipock View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Dec-2010
Location: Cherry Hill, NJ
Posts: 39
Post Options Post Options   Quote jipock Quote  Post ReplyReply Direct Link To This Post Topic: Query Strategy Not working??
    Posted: 07-Feb-2011 at 1:05pm
Good Afternoon,
 
I'm experiencing an issue regarding saving and retrieving values from a database. Please note, I don't really want ANY caching involved: I want this app to only look at the database.. Nothing else.. (Caching I'll implement later)
 
I have my application built up and I have two users running simultaneously. I'm seeing that some User A's Changes are not being seen by User B's changes at all...  "This.. Is bad.."
 
My first thought was, "My Query Strategy isn't right." But, it seems right to me...
 
My Entity Manager has the following:

DataStore.Instance.Entities.DefaultQueryStrategy = new QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.OverwriteChanges);

I don't specify (to my knowledge) anything special in my Entities.SaveChangesAsync() calls.
 
Is there something else I need to do?
 
-Jason
Back to Top
jipock View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Dec-2010
Location: Cherry Hill, NJ
Posts: 39
Post Options Post Options   Quote jipock Quote  Post ReplyReply Direct Link To This Post Posted: 07-Feb-2011 at 1:06pm
A quick note - When User A exits the app and re-starts the app, I see all of the changes.
 
 
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 07-Feb-2011 at 2:07pm
Even though you are specifying a query strategy, do you have some mechanism in the client to actually refresh the data? Otherwise how does it know that there is new data available?

What I mean by this is, even though you have the query strategy set, that doesn't stop DevForce from caching. Until you actually execute the query again, it will used what was cached.


Edited by smi-mark - 07-Feb-2011 at 5:15pm
Back to Top
jipock View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Dec-2010
Location: Cherry Hill, NJ
Posts: 39
Post Options Post Options   Quote jipock Quote  Post ReplyReply Direct Link To This Post Posted: 08-Feb-2011 at 1:41pm

A fair question.

Essentially it works like this:
 
1) User clicks a button.
2) ChildWindow opens up.
3) I have a query (var q = MyEntityManager.MyObjects.Where(qu => qu.Id = x); ) is executed. An ObservableCollection is populated based upon the results of the query and put into a list.
4) User updates the list.
5) User clicks Save.
6) MyEntityManager.SaveChangesAsync() is fired.
7) When step 6 is finished, the Child Window closes.
8) I use a SQL Statement in Management studio to update a value in MyObjects table where qu.Id = x. The value is different than that which was entered in step 4.
8) User Repeats step 1. Steps 2 and 3 run.
9) The list reflects the value that the user originally put in, NOt the value manually added in the database.
 
Note, this appears to be sporatic - I didn't experience this, this AM.
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 08-Feb-2011 at 4:49pm
Is DataStore.Instance.Entities always pointing to MyEntityManager?The only reason I could think of it not working would be a different EntityManager. You could test this by doing:

MyEntityManager.MyObjects.Where(qu => qu.Id = x).With(QueryStrategy.DataSourceOnly);


If this still returns the cached copy, then there is an issue somewhere
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 09-Feb-2011 at 5:10pm
Hi jipock,
 
I tried reproducing your issue, but was not able to.
 
As smi-mark mentioned, it might be that you are using a different EM. (Are you working with multiple Ems?)
 
If that's not the case, can you provide a reproducible test sample?
 
Silvio.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down