示例#1
0
 public WorkItemCleanupJob(TimeSpan interval, TimeSpan spanToKeepRecords, IWorkItemsContext context)
     : base("WorkItem Table Cleanup", interval)
 {
     if (spanToKeepRecords < TimeSpan.Zero)
     {
         throw new ArgumentException("Need to specify a positive time span.", "spanToKeepRecords");
     }
     SpanToKeepRecords = spanToKeepRecords;
     _context          = context;
 }
示例#2
0
 public void RunInTransaction(Action query)
 {
     using (var transaction = new TransactionScope())
     {
         // For some reason, I get different behavior when I use this
         // instead of _context.Database.Connection. This works, that doesn't. :(
         ((IObjectContextAdapter)_context).ObjectContext.Connection.Open();
         query();
         transaction.Complete();
     }
     // REVIEW: Make sure this is really needed. I kept running into
     // exceptions when I didn't do this, but I may be doing it wrong. -Phil 10/17/2011
     _context.Dispose();
     _context = _contextThunk();
 }
示例#3
0
 public EntityWorkItemRepository(Func <IWorkItemsContext> contextThunk)
 {
     _contextThunk = contextThunk;
     _context      = _contextThunk();
 }