New Posts New Posts RSS Feed: Updating Cache from Another Table
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Updating Cache from Another Table

 Post Reply Post Reply
Author
jmarbutt View Drop Down
DevForce MVP
DevForce MVP


Joined: 04-Jun-2010
Posts: 17
Post Options Post Options   Quote jmarbutt Quote  Post ReplyReply Direct Link To This Post Topic: Updating Cache from Another Table
    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?

Edited by jmarbutt - 07-Jun-2010 at 1:41pm
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post 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).
Back to Top
jmarbutt View Drop Down
DevForce MVP
DevForce MVP


Joined: 04-Jun-2010
Posts: 17
Post Options Post Options   Quote jmarbutt Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down