|
|
@ -72,12 +72,22 @@ namespace SqlSugar |
|
|
|
} |
|
|
|
return resul; |
|
|
|
} |
|
|
|
|
|
|
|
[Obsolete("use ExecuteCommand")] |
|
|
|
public object ExecuteReturnPrimaryKey() |
|
|
|
{ |
|
|
|
return ExecuteCommand(); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<object> ExecuteCommandAsync() |
|
|
|
{ |
|
|
|
object resut = 0; |
|
|
|
await Task.Run(() => |
|
|
|
{ |
|
|
|
resut= ExecuteCommand(); |
|
|
|
}); |
|
|
|
return resut; |
|
|
|
} |
|
|
|
public object ExecuteCommand() |
|
|
|
{ |
|
|
|
var isNoTrean = this.Context.Ado.Transaction == null; |
|
|
@ -126,7 +136,7 @@ namespace SqlSugar |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Obsolete("use ExecuteCommandAsync")] |
|
|
|
public Task<object> ExecuteReturnPrimaryKeyAsync() |
|
|
|
{ |
|
|
|
return Task.FromResult(ExecuteReturnPrimaryKey()); |
|
|
@ -191,7 +201,15 @@ namespace SqlSugar |
|
|
|
int id = 0; |
|
|
|
if (isIdentity) |
|
|
|
{ |
|
|
|
id = this.Context.Insertable(insert).AS(tableName).ExecuteReturnIdentity(); |
|
|
|
if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL) |
|
|
|
{ |
|
|
|
var sqlobj = this.Context.Insertable(insert).AS(tableName).ToSql(); |
|
|
|
id = this.Context.Ado.GetInt(sqlobj.Key+ " "+ entityInfo.Columns.First(it=>isIdentity).DbColumnName, sqlobj.Value); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
id = this.Context.Insertable(insert).AS(tableName).ExecuteReturnIdentity(); |
|
|
|
} |
|
|
|
if (this.Context.CurrentConnectionConfig.DbType == DbType.Oracle&&id==0) |
|
|
|
{ |
|
|
|
var seqName=entityInfo.Columns.First(it => it.OracleSequenceName.HasValue())?.OracleSequenceName; |
|
|
|