mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 18:34:55 +08:00
Update core
This commit is contained in:
@@ -72,12 +72,22 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return resul;
|
return resul;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("use ExecuteCommand")]
|
[Obsolete("use ExecuteCommand")]
|
||||||
public object ExecuteReturnPrimaryKey()
|
public object ExecuteReturnPrimaryKey()
|
||||||
{
|
{
|
||||||
return ExecuteCommand();
|
return ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<object> ExecuteCommandAsync()
|
||||||
|
{
|
||||||
|
object resut = 0;
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
resut= ExecuteCommand();
|
||||||
|
});
|
||||||
|
return resut;
|
||||||
|
}
|
||||||
public object ExecuteCommand()
|
public object ExecuteCommand()
|
||||||
{
|
{
|
||||||
var isNoTrean = this.Context.Ado.Transaction == null;
|
var isNoTrean = this.Context.Ado.Transaction == null;
|
||||||
@@ -126,7 +136,7 @@ namespace SqlSugar
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[Obsolete("use ExecuteCommandAsync")]
|
||||||
public Task<object> ExecuteReturnPrimaryKeyAsync()
|
public Task<object> ExecuteReturnPrimaryKeyAsync()
|
||||||
{
|
{
|
||||||
return Task.FromResult(ExecuteReturnPrimaryKey());
|
return Task.FromResult(ExecuteReturnPrimaryKey());
|
||||||
@@ -191,7 +201,15 @@ namespace SqlSugar
|
|||||||
int id = 0;
|
int id = 0;
|
||||||
if (isIdentity)
|
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)
|
if (this.Context.CurrentConnectionConfig.DbType == DbType.Oracle&&id==0)
|
||||||
{
|
{
|
||||||
var seqName=entityInfo.Columns.First(it => it.OracleSequenceName.HasValue())?.OracleSequenceName;
|
var seqName=entityInfo.Columns.First(it => it.OracleSequenceName.HasValue())?.OracleSequenceName;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
@@ -10,5 +11,6 @@ namespace SqlSugar
|
|||||||
[Obsolete("use ExecuteCommand")]
|
[Obsolete("use ExecuteCommand")]
|
||||||
object ExecuteReturnPrimaryKey();
|
object ExecuteReturnPrimaryKey();
|
||||||
object ExecuteCommand();
|
object ExecuteCommand();
|
||||||
|
Task<object> ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
@@ -289,6 +290,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
||||||
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
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");
|
connection = connection.Replace(oldDatabaseName, "mysql");
|
||||||
var newDb = new SqlSugarClient(new ConnectionConfig()
|
var newDb = new SqlSugarClient(new ConnectionConfig()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -461,9 +461,16 @@ namespace SqlSugar
|
|||||||
if (isCreatePrimaryKey)
|
if (isCreatePrimaryKey)
|
||||||
{
|
{
|
||||||
var pkColumns = columns.Where(it => it.IsPrimarykey).ToList();
|
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;
|
return true;
|
||||||
|
|||||||
@@ -826,32 +826,33 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
result = NoSameThreadAndShard();
|
result = NoSameThreadAndShard();
|
||||||
}
|
}
|
||||||
else if (IsSynchronization())
|
else
|
||||||
{
|
{
|
||||||
result = Synchronization();
|
result = Synchronization();
|
||||||
}
|
}
|
||||||
else if (IsSingleInstanceAsync())
|
///Because SqlSugarScope implements thread safety
|
||||||
{
|
//else if (IsSingleInstanceAsync())
|
||||||
result = Synchronization();//Async no support Single Instance
|
//{
|
||||||
}
|
// result = Synchronization();//Async no support Single Instance
|
||||||
else if (IsAsync())
|
//}
|
||||||
{
|
//else if (IsAsync())
|
||||||
result = Synchronization();
|
//{
|
||||||
}
|
// result = Synchronization();
|
||||||
else
|
//}
|
||||||
{
|
//else
|
||||||
StackTrace st = new StackTrace(true);
|
//{
|
||||||
var methods = st.GetFrames();
|
// StackTrace st = new StackTrace(true);
|
||||||
var isAsync = UtilMethods.IsAnyAsyncMethod(methods);
|
// var methods = st.GetFrames();
|
||||||
if (isAsync)
|
// var isAsync = UtilMethods.IsAnyAsyncMethod(methods);
|
||||||
{
|
// if (isAsync)
|
||||||
result = Synchronization();
|
// {
|
||||||
}
|
// result = Synchronization();
|
||||||
else
|
// }
|
||||||
{
|
// else
|
||||||
result = NoSameThread();
|
// {
|
||||||
}
|
// result = NoSameThread();
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
if (result.Root == null)
|
if (result.Root == null)
|
||||||
{
|
{
|
||||||
result.Root = this;
|
result.Root = this;
|
||||||
|
|||||||
Reference in New Issue
Block a user