Print Page | Close Window

Updating Cache from Another Table

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=1868
Printed Date: 22-May-2025 at 12:21pm


Topic: Updating Cache from Another Table
Posted By: jmarbutt
Subject: Updating Cache from Another Table
Date Posted: 07-Jun-2010 at 1:02pm
We have a large application with about 300 tables, and one audit table. The audit table contains the Id in the other tables as well as an UpdateDate.

I would like to be able to make one call to the AuditTable like:

var query = from a in MyEntities.AuditTable where UpdateDate > LastUpdate

And then be able to figure out what other entities need to be updated from that result set. What is the easiest way to do this? I don't want to have write special cases for each of these tables so what is the ideal way?



Replies:
Posted By: GregD
Date Posted: 07-Jun-2010 at 4:29pm
I'm not sure I understand what the problem is you're trying to solve. If you have an Audit entity, and you retrieve instances of it using the query you propose, then you'll have all the information you need, won't you? Your collection of Audit entities is the record of all entities that need to be refreshed in cache (provided they're there to begin with).


Posted By: jmarbutt
Date Posted: 07-Jun-2010 at 5:02pm
Well sort of, I guess was trying to figure out the easiest way to tell the other table to update the entity. That way when I add tables down the road it will update with out a special case.

The only way I see it is to do something like this:

switch TableName

case "People"
var query = from p in entities.people where p.id = id
select p;

case "Orders"
var query = from p in entities.orders where p.id = id
select p;
....
....
end switch


I was looking for a better way if that is possible


Posted By: GregD
Date Posted: 09-Jun-2010 at 6:34pm
There is a RefetchEntitiesAsync() method on the EntityManager that takes an EntityKeyList, and there's quite a bit of metadata available on any Entity, including what the EntityKey is, so very likely you can abstract it.



Print Page | Close Window