Print Page | Close Window

Query Strategy Not working??

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2493
Printed Date: 24-Jan-2026 at 1:18am


Topic: Query Strategy Not working??
Posted By: jipock
Subject: Query Strategy Not working??
Date 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



Replies:
Posted By: jipock
Date 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.
 
 


Posted By: smi-mark
Date 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.


Posted By: jipock
Date 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.


Posted By: smi-mark
Date 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


Posted By: sbelini
Date 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.



Print Page | Close Window