//public int Insert(T entity) //{ // SqlProvider.FormatInsert(entity); // return Exec(SqlProvider.SqlString, SqlProvider.Params, _dbTransaction); //} public int Insert(T entity) { SqlProvider.FormatInsert(entity, out var isHaveIdentity, out var property); SetSql(); if (isHaveIdentity == System.ComponentModel.DataAnnotations.IdentityTypeEnum.Int) { var id = DbCon.ExecuteScalar <int>(SqlProvider.SqlString, SqlProvider.Params, _dbTransaction); return(id); } else if (isHaveIdentity == System.ComponentModel.DataAnnotations.IdentityTypeEnum.Guid) { var gi = DbCon.ExecuteScalar <Guid>(SqlProvider.SqlString, SqlProvider.Params, _dbTransaction); property.SetValue(entity, gi); return(1); } else { var r = Exec(SqlProvider.SqlString, SqlProvider.Params, _dbTransaction); return(r); } }
public async Task <int> InsertAsync(T entity) { SqlProvider.FormatInsert(entity, out var isHaveIdentity, out var property); SetSql(); int result; if (isHaveIdentity == System.ComponentModel.DataAnnotations.IdentityTypeEnum.Int) { result = await DbCon.ExecuteScalarAsync <int>(SqlProvider.SqlString, SqlProvider.Params, _dbTransaction); } else if (isHaveIdentity == System.ComponentModel.DataAnnotations.IdentityTypeEnum.Guid) { var gi = await DbCon.ExecuteScalarAsync <Guid>(SqlProvider.SqlString, SqlProvider.Params, _dbTransaction); property.SetValue(entity, gi); result = 1; } else { result = await ExecAsync(SqlProvider.SqlString, SqlProvider.Params, _dbTransaction); } return(result); }
public int Insert(T entity) { SqlProvider.FormatInsert(entity); return(DbCon.Execute(SqlProvider.SqlString, SqlProvider.Params, DbTransaction)); }
public int Insert(T entity, string[] excludeFields = null) { SqlProvider.FormatInsert(entity, excludeFields); return(DbCon.Execute(SqlProvider.SqlString, SqlProvider.Params, DbTransaction)); }
public async Task <int> InsertAsync(T entity) { SqlProvider.FormatInsert(entity); return(await DbCon.ExecuteAsync(SqlProvider.SqlString, SqlProvider.Params, DbTransaction)); }
public async Task <int> InsertAsync(T entity, string[] excludeFields = null) { SqlProvider.FormatInsert(entity, excludeFields); return(await DbCon.ExecuteAsync(SqlProvider.SqlString, SqlProvider.Params, DbTransaction)); }
public async Task <int> InsertAsync(IEnumerable <T> entities, string[] excludeFields = null, int timeout = 120) { SqlProvider.FormatInsert(entities.FirstOrDefault(), excludeFields); return(await DbCon.ExecuteAsync(SqlProvider.SqlString, entities, DbTransaction, timeout)); }
public async Task <int> InsertAsync(IEnumerable <T> entities, string[] excludeFields = null, int timeout = 120) { SqlProvider.FormatInsert(entities, excludeFields); return(await DbCon.ExecuteAsync(SqlProvider.SqlString, SqlProvider.Params, DbTransaction, timeout, isExcludeUnitOfWork : SqlProvider.IsExcludeUnitOfWork)); }
public int Insert(IEnumerable <T> entities, string[] excludeFields = null, int timeout = 120) { SqlProvider.FormatInsert(entities.FirstOrDefault(), excludeFields); return(DbCon.Execute(SqlProvider.SqlString, entities, DbTransaction, timeout, isExcludeUnitOfWork: SqlProvider.IsExcludeUnitOfWork)); }