コード例 #1
0
 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);
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
 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);
     }
 }