Пример #1
0
 public static UnitOfWork Start()
 {
     if (current != null)
     {
         throw new InvalidOperationException(string.Format("Cannot start current unit of work {0} because it is already started. Thread: {1}", current.id, Thread.CurrentThread.ManagedThreadId));
     }
     current = new UnitOfWork { Session = SessionFactory.New(), id = Guid.NewGuid() };
     Log.Debug("Starting unit of work {0}. Thread: {1}", current.id, Thread.CurrentThread.ManagedThreadId);
     current.Session.Open();
     return current;
 }
Пример #2
0
 public void Dispose()
 {
     Log.Debug("Disposing unit of work {0}. Thread: {1}", current.id, Thread.CurrentThread.ManagedThreadId);
     Session.Dispose();
     current = null;
 }