I'm having trouble with refreshing objects in my database. I have an two PC's and two applications.
On the first PC, there's an application which communicates with my database and adds some data to Measurements table. On my other PC, there's an application which retrives the latest Measurement under a timer, so it should retrive measurements added by the application on my first PC too.
The problem is it doesn't. On my application start, it caches all the data from database and never get new data added. I use Refresh() method which works well when I change any of the cached data, but it doesn't refresh newly added data.
Here is my method which should update the data:
public static Entities myEntities = new Entities();
public static Measurement GetLastMeasurement(int conditionId)
{
myEntities.Refresh(RefreshMode.StoreWins, myEntities.Measurements);
return (from measurement in myEntities.Measurements
where measurement.ConditionId == conditionId
select measurement).OrderByDescending(cd => cd.Timestamp).First();
}
P.S. Applications have different connection strings in app.config (different accounts for the same DB).