Ejemplo n.º 1
0
 public IUnitOfWorkGeneric <TEntity> CreateUoW <TEntity>(IUnitOfWorkFactory unitOfWorkFactory) where TEntity : class, IDomainObject, new()
 {
     if (IsNewEntity)
     {
         if (RootUoW == null)
         {
             return(unitOfWorkFactory.CreateWithNewRoot <TEntity>());
         }
         else
         {
             return(unitOfWorkFactory.CreateWithNewChildRoot <TEntity>(RootUoW));
         }
     }
     else
     {
         if (RootUoW == null)
         {
             return(unitOfWorkFactory.CreateForRoot <TEntity>(EntityOpenId));
         }
         else
         {
             return(unitOfWorkFactory.CreateForChildRoot <TEntity>(RootUoW.GetById <TEntity>(EntityOpenId), RootUoW));
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Создаем дочерний Unit of Work не использующий коммит при сохранении Root
 /// </summary>
 /// <returns>UnitOfWork.</returns>
 /// <typeparam name="TChildRootEntity">Тип объекта доменной модели, должен реализовывать интерфейс IDomainObject.</typeparam>
 public static IUnitOfWorkGeneric <TChildRootEntity> CreateForChildRoot <TChildRootEntity>(TChildRootEntity childRoot, IUnitOfWork parentUoW, string userActionTitle = null, [CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0)
     where TChildRootEntity : class, IDomainObject, new()
 {
     return(unitOfWorkFactory.CreateForChildRoot <TChildRootEntity>(childRoot, parentUoW, userActionTitle, callerMemberName, callerFilePath, callerLineNumber));
 }