Ejemplo n.º 1
0
        /// <summary>
        ///     批量插入实体记录集合
        /// </summary>
        /// <param name="entities"> 实体记录集合 </param>
        /// <param name="isSave"> 是否执行保存 </param>
        /// <returns> 操作影响的行数 </returns>
        public int Insert(IEnumerable <TEntity> entities, bool isSave = true)
        {
            PublicHelper.CheckArgument(entities, "entities");

            EFContext.RegisterNew(entities);
            return(isSave ? EFContext.Commit() : 0);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public int Insert(TEntity entity, bool isSave = true)
 {
     PublicHelper.CheckArgument(entity, "entity");
     EFContext.RegisterNew(entity);
     //如果是单个直接提交到数据库即可
     return(isSave ? EFContext.Commit() : 0);
 }
Ejemplo n.º 3
0
        /// <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");
            EFContext.RegisterNew <TEntity, TKey>(entity);

            return(isSave ? EFContext.Commit() : 0);
        }
Ejemplo n.º 4
0
 public bool SaveOrUpdate(T entity, bool isAdd = false, bool isCommit = true)
 {
     if (isAdd)
     {
         EFContext.RegisterNew(entity);
     }
     else
     {
         EFContext.RegisterModified(entity);
     }
     return(isCommit ? EFContext.Commit() > 0 : false);
 }
Ejemplo n.º 5
0
        /// <summary>
        ///     插入实体记录
        /// </summary>
        /// <param name="entity"> 实体对象 </param>
        /// <param name="isSave"> 是否执行保存 </param>
        /// <returns> 操作影响的行数 </returns>
        public virtual OperationResult Insert(TEntity entity, bool isSave = true)
        {
            PublicHelper.CheckArgument(entity, "entity");
            OperationResult operationResult = new OperationResult(OperationResultType.Success);

            EFContext.RegisterNew(entity);
            int number = (isSave ? EFContext.Commit() : 0);

            operationResult.Message    = "添加成功:" + number + "条数据";
            operationResult.AppendData = number;
            return(operationResult);
        }
Ejemplo n.º 6
0
 /// <summary>
 ///     批量插入实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Insert(IEnumerable <TEntity> entities, bool isSave = true)
 {
     if (entities != null && entities.Count() > 0)
     {
         //PublicHelper.CheckArgument(entities, "entities");
         EFContext.RegisterNew(entities);
         return(isSave ? EFContext.Commit() : 0);
     }
     else
     {
         return(0);
     }
 }
Ejemplo n.º 7
0
 public bool SaveOrUpdateForList(List <T> entities, bool isAdd = false, bool isCommit = true)
 {
     foreach (var item in entities)
     {
         if (isAdd)
         {
             EFContext.RegisterNew(item);
         }
         else
         {
             EFContext.RegisterModified(item);
         }
     }
     return(isCommit ? EFContext.Commit() > 0 : false);
 }
Ejemplo n.º 8
0
 /// <summary>
 ///     插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual DataResult Insert(TEntity entity, bool isSave = true)
 {
     //DbContextBase context = new DbContextBase();
     //context.Set<TEntity>().Add(entity);
     //return isSave?context.SaveChanges():0;
     EFContext.RegisterNew <TEntity, TKey>(entity);
     //if (isSave)
     //{
     //    if (EFContext.Commit() >= 0)
     //        return DataProcess.Success();
     //    else
     //        return DataProcess.Failure();
     //}
     //return null;
     return(isSave ? EFContext.Commit() : null);
     //_dbSet.Add(entity);
     //return isSave ? UnitOfWork.Commit() : 0;
 }
Ejemplo n.º 9
0
 public virtual int Insert(IEnumerable <TEntity> entities, bool isSave = true)
 {
     EFContext.RegisterNew <TEntity, TKey>(entities);
     return(isSave ? EFContext.Submit() : 0);
 }
Ejemplo n.º 10
0
 /// <summary>
 ///     插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Insert(TEntity entity, bool isSave = true)
 {
     Check.NotNull(entity, "entity");
     EFContext.RegisterNew(entity);
     return(isSave ? EFContext.Commit() : 0);
 }
Ejemplo n.º 11
0
 public int Insert(IEnumerable <TEntity> entities, bool isSave = true)
 {
     EFContext.RegisterNew(entities);
     return(isSave ? EFContext.Commit() : 0);
 }
Ejemplo n.º 12
0
 public virtual int Insert(TEntity entity, bool isSave = true)
 {
     EFContext.RegisterNew <TEntity, TKey>(entity);
     return(isSave ? EFContext.Submit() : 0);
 }
Ejemplo n.º 13
0
 /// <summary>
 ///     插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual bool Add(T entity, bool isSave = true)
 {
     EFContext.RegisterNew(entity);
     return(isSave ? EFContext.Commit() > 0 : false);
 }
Ejemplo n.º 14
0
 public int Insert(TEntity entity, bool isSave = true)
 {
     EFContext.RegisterNew(entity);
     return(isSave ? EFContext.Commit() : 0);
 }
Ejemplo n.º 15
0
 /// <summary>
 ///     批量插入实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Add(IEnumerable <T> entities, bool isSave = true)
 {
     EFContext.RegisterNew(entities);
     return(isSave ? EFContext.Commit() : 0);
 }
Ejemplo n.º 16
0
 /// <summary>
 ///     插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual DataResult Insert(TEntity entity, bool isSave = true)
 {
     EFContext.RegisterNew <TEntity, TKey>(entity);
     return(isSave ? EFContext.Commit() : null);
 }
Ejemplo n.º 17
0
 public int Insert(IEquatable <T> entities, bool isCommit = true)
 {
     EFContext.RegisterNew(entities);
     return(isCommit ? EFContext.Commit() : 0);
 }
Ejemplo n.º 18
0
 /// <summary>
 ///     批量插入实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="saveNow"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Insert(IEnumerable <TEntity> entities, bool saveNow = true, bool validateOnSaveEnabled = true)
 {
     PublicHelper.CheckArgument(entities, "entities");
     EFContext.RegisterNew <TEntity, TKeyType>(entities);
     return(saveNow ? EFContext.Commit(validateOnSaveEnabled) : 0);
 }
Ejemplo n.º 19
0
 /// <summary>
 ///     插入实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Insert(TEntity entity, bool isSave = true)
 {
     Argument.NullParam(entity, entity.GetType().Name);
     EFContext.RegisterNew(entity);
     return(isSave ? EFContext.Commit() : 0);
 }
Ejemplo n.º 20
0
 /// <summary>
 ///     批量插入实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Insert(IEnumerable <TEntity> entities, bool isSave = true)
 {
     Check.NotNull(entities, "entities");
     EFContext.RegisterNew(entities);
     return(isSave ? EFContext.Commit() : 0);
 }
Ejemplo n.º 21
0
 public virtual int Insert(T entity, bool isCommit = true)
 {
     EFContext.RegisterNew(entity);
     return(isCommit ? EFContext.Commit() : 0);
 }