public virtual void Delete(IReadOnlyCollection <T> objs) { if (objs.Count == 0) { return; } foreach (T cr in objs) { BeginDeleteCallback?.Invoke(cr); } using (var session = DatabaseFactory.SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { foreach (T cr in objs) { DeleteWithOpenTransactionCallback?.Invoke(session, cr); Cache.Remove(cr); session.Delete(cr); } transaction.Commit(); } } foreach (T cr in objs) { EndDeleteCallback?.Invoke(cr); } }
public virtual void Delete(T cr) { if (cr == null) { return; } BeginDeleteCallback?.Invoke(cr); lock (globalDBLock) { lock (Cache) { using (var session = DatabaseFactory.SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { DeleteWithOpenTransactionCallback?.Invoke(session, cr); Cache.Remove(cr); session.Delete(cr); transaction.Commit(); } } } } EndDeleteCallback?.Invoke(cr); }
public virtual void Delete(List <T> objs) { if (objs.Count == 0) { return; } foreach (T obj in objs) { BeginDeleteCallback?.Invoke(obj); } using (var session = JMMService.SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { foreach (T cr in objs) { DeleteWithOpenTransactionCallback?.Invoke(session, cr); session.Delete(cr); } transaction.Commit(); } } foreach (T obj in objs) { EndDeleteCallback?.Invoke(obj); } }
public virtual void Delete(T cr) { if (cr != null) { BeginDeleteCallback?.Invoke(cr); using (var session = DatabaseFactory.SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { DeleteWithOpenTransactionCallback?.Invoke(session, cr); session.Delete(cr); transaction.Commit(); } } EndDeleteCallback?.Invoke(cr); } }