/// <summary>
 /// 插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Insert(TEntity entity, bool isSave = true)
 {
     PublicHelper.CheckArgument(entity, "entity");
     UnitOfWorkContext.RegisterNew(entity);
     return(isSave ? Save() : 0);
 }
 /// <summary>
 /// 批量插入实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Insert(IEnumerable <TEntity> entities, bool isSave = true)
 {
     PublicHelper.CheckArgument(entities, "entities");
     UnitOfWorkContext.RegisterNew(entities);
     return(isSave ? Save() : 0);
 }
 /// <summary>
 /// 批量插入实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual async Task <int> InsertAsync(IEnumerable <TEntity> entities, bool isSave = true)
 {
     PublicHelper.CheckArgument(entities, "entities");
     UnitOfWorkContext.RegisterNew(entities);
     return(isSave ? await SaveAsync() : 0);
 }
 /// <summary>
 /// 插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual async Task <int> InsertAsync(TEntity entity, bool isSave = true)
 {
     PublicHelper.CheckArgument(entity, "entity");
     UnitOfWorkContext.RegisterNew(entity);
     return(isSave ? await SaveAsync() : 0);
 }
Example #5
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="aggregateRoot"></param>
 public virtual void Add(TEntity aggregateRoot)
 {
     lazy.RegisterNew <TEntity>(aggregateRoot);
     lazy.Commit();
 }
Example #6
0
 public virtual int Insert(IEnumerable <TEntity> entities, bool isSave = true)
 {
     UnitOfWorkContext.RegisterNew(entities);
     return(isSave ? UnitOfWorkContext.Commit() : 0);
 }
Example #7
0
 public virtual int Insert(TEntity entity, bool isSave = true)
 {
     UnitOfWorkContext.RegisterNew(entity);
     return(isSave ? UnitOfWorkContext.Commit() : 0);
 }