public async Task <int> BatchInsertAsync <T>(List <T> list) where T : BaseEntity { if (list != null && list.Count > 0) { string sql = SQLBuilderHelper.GetInsertSql(list.First(), this.GetORMDBType()); return(await ExcuteAsync(sql, list)); } return(0); }
/// <summary> /// 批量新增 (新增相同的列) /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <returns></returns> public int BatchInsert <T>(List <T> list) where T : BaseEntity { int ret = 0; if (list != null && list.Count > 0) { string sql = SQLBuilderHelper.GetInsertSql(list.First(), this.GetORMDBType()); ret = Excute(sql, list); } return(ret); }
/// <summary> /// 如果主键是自增返回插入主键 否则返回0 /// </summary> /// <param name="model"></param> /// <returns></returns> public long Insert(BaseEntity entity) { string sql = SQLBuilderHelper.GetInsertSql(entity, this.GetORMDBType()); return(ExecuteAndTrace(sql, entity, () => { using (ConnectionManager mgr = GetConnection()) { return mgr.Connection.QuerySingle <long>(sql, entity, mgr.Transaction, null, CommandType.Text); } })); }
public async Task <long> InsertAsync(BaseEntity entity) { string sql = SQLBuilderHelper.GetInsertSql(entity, this.GetORMDBType()); return(await ExecuteAndTraceAsync(sql, entity, async() => { using (ConnectionManager mgr = GetConnection()) { var result = await mgr.Connection.QuerySingleAsync <long>(sql, entity, mgr.Transaction, null, CommandType.Text); return result; } })); }