mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update core
This commit is contained in:
parent
1f2f136f74
commit
e5262980cb
@ -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;
|
||||
|
@ -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,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()
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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…
Reference in New Issue
Block a user