Browse Source

Support OleDb Insert

pull/14/head
sunkaixuan 3 years ago
parent
commit
8aa6beee1e
  1. 3
      Src/Asp.Net/SqlSugar.Access/Access/SqlBuilder/AccessInsertBuilder.cs
  2. 22
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  3. 1
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

3
Src/Asp.Net/SqlSugar.Access/Access/SqlBuilder/AccessInsertBuilder.cs

@ -8,6 +8,7 @@ namespace SqlSugar.Access
{
public class AccessInsertBuilder : InsertBuilder
{
public override bool IsOleDb { get; set; } = true;
public override string SqlTemplate
{
get
@ -17,7 +18,7 @@ namespace SqlSugar.Access
return @"INSERT INTO {0}
({1})
VALUES
({2}) ;";
({2}) ;select @@identity";
}
else
{

22
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -69,7 +69,16 @@ namespace SqlSugar
return 0;
}
string sql = _ExecuteReturnIdentity();
var result = Ado.GetInt(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
var result = 0;
if (InsertBuilder.IsOleDb)
{
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());
}
else
{
result = Ado.GetInt(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
}
After(sql, result);
return result;
}
@ -81,7 +90,16 @@ namespace SqlSugar
return 0;
}
string sql = _ExecuteReturnBigIdentity();
var result = Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()));
long result = 0;
if (InsertBuilder.IsOleDb)
{
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()));
}
else
{
result= Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()));
}
After(sql, result);
return result;
}

1
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

@ -30,6 +30,7 @@ namespace SqlSugar
public EntityInfo EntityInfo { get; set; }
public Dictionary<string, int> OracleSeqInfoList { get; set; }
public bool IsBlukCopy { get; set; }
public virtual bool IsOleDb { get; set; }
#endregion
#region SqlTemplate

Loading…
Cancel
Save