diff --git a/Src/Asp.Net/AccessTest/Demo/Demo3_Insertable.cs b/Src/Asp.Net/AccessTest/Demo/Demo3_Insertable.cs index 8fa85bb42..e21c67c5c 100644 --- a/Src/Asp.Net/AccessTest/Demo/Demo3_Insertable.cs +++ b/Src/Asp.Net/AccessTest/Demo/Demo3_Insertable.cs @@ -39,7 +39,7 @@ namespace OrmTest //var x=db.Insertable(insertObjs).RemoveDataCache().IgnoreColumns(it=>it.CreateTime).UseParameter().ExecuteCommand(); //Ignore CreateTime - db.Insertable(insertObj).IgnoreColumns(it => new { it.CreateTime }).ExecuteReturnIdentity();//get identity + var x= db.Insertable(insertObj).IgnoreColumns(it => new { it.CreateTime }).ExecuteReturnIdentity();//get identity db.Insertable(insertObj).IgnoreColumns("CreateTime").ExecuteReturnIdentity(); //Only insert Name and Price diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index d6ee50773..2547d4300 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -72,8 +72,19 @@ namespace SqlSugar var result = 0; if (InsertBuilder.IsOleDb) { + var isAuto = false; + if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection) + { + isAuto = true; + this.Context.CurrentConnectionConfig.IsAutoCloseConnection = false; + } result = Ado.GetInt(sql.Split(';').First(), InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()); result = Ado.GetInt(sql.Split(';').Last(), InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()); + if (isAuto) + { + this.Ado.Close(); + this.Context.CurrentConnectionConfig.IsAutoCloseConnection = isAuto; + } } else { @@ -93,8 +104,19 @@ namespace SqlSugar long result = 0; if (InsertBuilder.IsOleDb) { + var isAuto = false; + if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection) + { + isAuto = true; + this.Context.CurrentConnectionConfig.IsAutoCloseConnection = false; + } result = Convert.ToInt64(Ado.GetScalar(sql.Split(';').First(), InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray())); result = Convert.ToInt64(Ado.GetScalar(sql.Split(';').Last(), InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray())); + if (isAuto) + { + this.Ado.Close(); + this.Context.CurrentConnectionConfig.IsAutoCloseConnection = isAuto; + } } else {