mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 20:43:46 +08:00
Update .net core project
This commit is contained in:
@@ -183,6 +183,14 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Transaction
|
#region Transaction
|
||||||
|
public virtual bool IsAnyTran()
|
||||||
|
{
|
||||||
|
return this.Transaction != null;
|
||||||
|
}
|
||||||
|
public virtual bool IsNoTran()
|
||||||
|
{
|
||||||
|
return this.Transaction == null;
|
||||||
|
}
|
||||||
public virtual void BeginTran()
|
public virtual void BeginTran()
|
||||||
{
|
{
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
@@ -105,16 +105,32 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (isRoot && nav.Navigat.NavigatType != NavigateType.ManyToMany)
|
if (isRoot && nav.Navigat.NavigatType != NavigateType.ManyToMany)
|
||||||
{
|
{
|
||||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
UpdateRoot();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_Options != null && _Options.ManyToManyIsUpdateA)
|
if (_Options != null && _Options.ManyToManyIsUpdateA)
|
||||||
{
|
{
|
||||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
UpdateRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateRoot()
|
||||||
|
{
|
||||||
|
if (_Options != null && _Options.RootFunc != null)
|
||||||
|
{
|
||||||
|
var updateable = this._Context.Updateable(_Roots);
|
||||||
|
var exp= _Options.RootFunc as Expression<Action<IUpdateable<Root>>>;
|
||||||
|
Check.ExceptionEasy(exp == null, "UpdateOptions.RootFunc is error", "UpdateOptions.RootFunc");
|
||||||
|
var com= exp.Compile();
|
||||||
|
com(updateable);
|
||||||
|
updateable.ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,19 @@ namespace SqlSugar
|
|||||||
var insertData = x.InsertList.Select(it => it.Item).ToList();
|
var insertData = x.InsertList.Select(it => it.Item).ToList();
|
||||||
var updateData = x.UpdateList.Select(it => it.Item).ToList();
|
var updateData = x.UpdateList.Select(it => it.Item).ToList();
|
||||||
Check.ExceptionEasy(pkColumn == null && NavColumn == null, $"The entity is invalid", $"实体错误无法使用导航");
|
Check.ExceptionEasy(pkColumn == null && NavColumn == null, $"The entity is invalid", $"实体错误无法使用导航");
|
||||||
|
if (_Options != null && _Options.CurrentFunc != null)
|
||||||
|
{
|
||||||
|
var updateable = x.AsUpdateable;
|
||||||
|
var exp = _Options.CurrentFunc as Expression<Action<IUpdateable<TChild>>>;
|
||||||
|
Check.ExceptionEasy(exp == null, "UpdateOptions.CurrentFunc is error", "UpdateOptions.CurrentFunc参数设置错误");
|
||||||
|
var com = exp.Compile();
|
||||||
|
com(updateable);
|
||||||
|
updateable.ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
x.AsUpdateable.ExecuteCommand();
|
x.AsUpdateable.ExecuteCommand();
|
||||||
|
}
|
||||||
InitData(pkColumn, insertData);
|
InitData(pkColumn, insertData);
|
||||||
if (_NavigateType == NavigateType.OneToMany)
|
if (_NavigateType == NavigateType.OneToMany)
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ namespace SqlSugar
|
|||||||
public bool ManyToManyIsUpdateA { get; set; }
|
public bool ManyToManyIsUpdateA { get; set; }
|
||||||
public bool ManyToManyIsUpdateB { get; set; }
|
public bool ManyToManyIsUpdateB { get; set; }
|
||||||
public bool OneToManyDeleteAll { get; set; }
|
public bool OneToManyDeleteAll { get; set; }
|
||||||
|
public Expression RootFunc { get; set; }
|
||||||
|
public Expression CurrentFunc { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InsertNavOptions
|
public class InsertNavOptions
|
||||||
|
@@ -215,6 +215,7 @@ namespace SqlSugar
|
|||||||
+ Context.ParameterIndex;
|
+ Context.ParameterIndex;
|
||||||
if (value.ObjToString() != "NULL" && !parameter.ValueIsNull)
|
if (value.ObjToString() != "NULL" && !parameter.ValueIsNull)
|
||||||
{
|
{
|
||||||
|
value = this.Context.TableEnumIsString == true ? value.ToString() : value;
|
||||||
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
|
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -20,6 +20,8 @@ namespace SqlSugar
|
|||||||
SqlSugarProvider Context { get; set; }
|
SqlSugarProvider Context { get; set; }
|
||||||
void ExecuteBefore(string sql, SugarParameter[] pars);
|
void ExecuteBefore(string sql, SugarParameter[] pars);
|
||||||
void ExecuteAfter(string sql, SugarParameter[] pars);
|
void ExecuteAfter(string sql, SugarParameter[] pars);
|
||||||
|
bool IsAnyTran();
|
||||||
|
bool IsNoTran();
|
||||||
bool IsEnableLogEvent{get;set;}
|
bool IsEnableLogEvent{get;set;}
|
||||||
StackTraceInfo SqlStackTrace { get; }
|
StackTraceInfo SqlStackTrace { get; }
|
||||||
IDataParameterCollection DataReaderParameters { get; set; }
|
IDataParameterCollection DataReaderParameters { get; set; }
|
||||||
|
@@ -39,7 +39,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
this.Tenant.RollbackTran();
|
this.Tenant.RollbackTran();
|
||||||
}
|
}
|
||||||
if (IsClose == false)
|
if (this.Db.Ado.Transaction==null&&IsClose == false)
|
||||||
{
|
{
|
||||||
this.Db.Close();
|
this.Db.Close();
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ namespace SqlSugar
|
|||||||
this.Tenant.CommitTran();
|
this.Tenant.CommitTran();
|
||||||
IsCommit = true;
|
IsCommit = true;
|
||||||
}
|
}
|
||||||
if (this.IsClose == false)
|
if (this.Db.Ado.Transaction==null&&this.IsClose == false)
|
||||||
{
|
{
|
||||||
this.Db.Close();
|
this.Db.Close();
|
||||||
IsClose = true;
|
IsClose = true;
|
||||||
|
Reference in New Issue
Block a user