/// <summary> /// 批量更新 /// </summary> /// <param name="entityList"></param> /// <returns></returns> public virtual bool BatchUpdate_Entitys(List <T> entityList) { //使用事务进行批量数据更新 using (DbTrans trans = db.BeginTrans()) { try { DbBatch batch = trans.BeginBatch(entityList.Count); entityList.ForEach(item => { item.Attach(); batch.Save(item); }); batch.Process(); trans.Commit(); return(true); } catch { trans.Rollback(); return(false); } } }
/// <summary> /// 保存一个实体 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity"></param> /// <returns></returns> public int Save <T>(Table table, T entity) where T : Entity { return(dbBatch.Save <T>(table, entity)); }