Entity Framework Getting latest data
I'm building a scheduling system with Quartz.NET. My first approach is to
- Load all scheduled tasks from database (front end schedule definitions).
- Go through them all and set it up with Quartz (jobs/triggers etc).
- Every minute to ch开发者_开发问答eck if there are any changes in db so I can update my triggers/jobs.
So far I have done steps 1-3, however I'm unsure how to load only modified data - and to update its Quartz definitions.
At the moment I use
var activities = Entities.Activities.Where(w => !w.IsDeleted);
to load all data (not deleted). I thought there might be something like Entities.Activites.Where(w=>w.IsModified)
. I'm not that familiar with entity framework yet though.
Is there a method or parameter that would let me load just modified (delta) data?
Sounds like the simplest thing would be to add a simple LastUpdated field to your table(s) and use that to load items that have been changed since a particular point in time. Oh, and you might want to make sure you're storing all those times in UTC if you need to be concerned about time zones. It's always painful to make the switch later.
Alternately, if you don't want to worry about having the proper reference time to load updates, you could just add a Dirty column to the various tables (or its equivalent), load everything that's "dirty", process the records, and clear the flag.
精彩评论