mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
-
This commit is contained in:
@@ -75,7 +75,28 @@ namespace SqlSugar
|
||||
|
||||
public object ExecuteReturnPrimaryKey()
|
||||
{
|
||||
var isNoTrean = this.Context.Ado.Transaction == null;
|
||||
try
|
||||
{
|
||||
if (isNoTrean)
|
||||
this.Context.Ado.BeginTran();
|
||||
|
||||
var result = Execute();
|
||||
|
||||
if (isNoTrean)
|
||||
this.Context.Ado.CommitTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (isNoTrean)
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private object Execute()
|
||||
{
|
||||
if (InsertObjects != null && InsertObjects.Count() > 0)
|
||||
{
|
||||
var isIdEntity = IsIdEntity(this.Entity);
|
||||
|
Reference in New Issue
Block a user