Browse Source

Update OleDb

pull/14/head
sunkaixuan 3 years ago
parent
commit
ff6b157b36
  1. 2
      Src/Asp.Net/AccessTest/Demo/Demo3_Insertable.cs
  2. 22
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

2
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

22
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
{

Loading…
Cancel
Save