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; }
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(); }
public EntityWorkItemRepository(Func <IWorkItemsContext> contextThunk) { _contextThunk = contextThunk; _context = _contextThunk(); }