c# - UoW and DbContext fail in an event -
i have implemented windows service sends emails using sendasync method, every 30 seconds in batches of 20. i'm using ef6 , sql server 2016. here parts of codes emailrepository.cs public class emailrepository : iemailrepository { private bbentities db = null; public emailrepository(bbentities db) { this.db = db; } public ienumerable<tb_email> selectall(int batchage, int batchsize) { datetime tdate = datetime.now.addminutes(batchage); return db.tb_email.where(x => x.readytosend.equals(true) & x.datesent.equals(null) & x.datecreated >= tdate).orderby(x => x.datecreated).take(batchsize); } public tb_email selectbyid(guid id) { return db.tb_email.find(id); } public void update(tb_email obj) { db.entry(obj).state = entitystate.modified; } #region idisposable support private bool disposedvalue = false; protected virtual void dispose(bool disposing) ...