Browse Source

Update core

pull/8/head
sunkaixuna 3 years ago
parent
commit
e5262980cb
  1. 22
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/InsertableProvider/SubInserable.cs
  2. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/ISubInsertable.cs
  3. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs
  4. 11
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs
  5. 47
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarClient.cs

22
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/InsertableProvider/SubInserable.cs

@ -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;

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/ISubInsertable.cs

@ -1,5 +1,6 @@
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace SqlSugar
{
@ -10,5 +11,6 @@ namespace SqlSugar
[Obsolete("use ExecuteCommand")]
object ExecuteReturnPrimaryKey();
object ExecuteCommand();
Task<object> ExecuteCommandAsync();
}
}

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace SqlSugar
{
@ -289,6 +290,7 @@ namespace SqlSugar
}
var oldDatabaseName = this.Context.Ado.Connection.Database;
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
Check.Exception(Regex.Split(connection,oldDatabaseName).Length > 2, "The user name and password cannot be the same as the database name ");
connection = connection.Replace(oldDatabaseName, "mysql");
var newDb = new SqlSugarClient(new ConnectionConfig()
{

11
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs

@ -461,9 +461,16 @@ namespace SqlSugar
if (isCreatePrimaryKey)
{
var pkColumns = columns.Where(it => it.IsPrimarykey).ToList();
foreach (var item in pkColumns)
if (pkColumns.Count <=1)
{
this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName);
foreach (var item in pkColumns)
{
this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName);
}
}
else
{
this.Context.DbMaintenance.AddPrimaryKey(tableName, string.Join(",", pkColumns.Select(it=> this.SqlBuilder.GetTranslationColumnName(it.DbColumnName)).ToArray()));
}
}
return true;

47
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarClient.cs

@ -826,32 +826,33 @@ namespace SqlSugar
{
result = NoSameThreadAndShard();
}
else if (IsSynchronization())
else
{
result = Synchronization();
}
else if (IsSingleInstanceAsync())
{
result = Synchronization();//Async no support Single Instance
}
else if (IsAsync())
{
result = Synchronization();
}
else
{
StackTrace st = new StackTrace(true);
var methods = st.GetFrames();
var isAsync = UtilMethods.IsAnyAsyncMethod(methods);
if (isAsync)
{
result = Synchronization();
}
else
{
result = NoSameThread();
}
}
///Because SqlSugarScope implements thread safety
//else if (IsSingleInstanceAsync())
//{
// result = Synchronization();//Async no support Single Instance
//}
//else if (IsAsync())
//{
// result = Synchronization();
//}
//else
//{
// StackTrace st = new StackTrace(true);
// var methods = st.GetFrames();
// var isAsync = UtilMethods.IsAnyAsyncMethod(methods);
// if (isAsync)
// {
// result = Synchronization();
// }
// else
// {
// result = NoSameThread();
// }
//}
if (result.Root == null)
{
result.Root = this;

Loading…
Cancel
Save