Browse Source

Synchronization code

pull/31/head
sunkaixuan 2 years ago
parent
commit
8e12db2198
  1. 14
      Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
  2. 18
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs

14
Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs

@ -217,20 +217,18 @@ namespace SqlSugar
if (this.Transaction == null) if (this.Transaction == null)
this.Transaction =await (this.Connection as DbConnection).BeginTransactionAsync(); this.Transaction =await (this.Connection as DbConnection).BeginTransactionAsync();
} }
public virtual async Task BeginTranAsync(IsolationLevel iso)
{
await CheckConnectionAsync();
if (this.Transaction == null)
this.Transaction =await (this.Connection as DbConnection).BeginTransactionAsync(iso);
}
public virtual void BeginTran(IsolationLevel iso) public virtual void BeginTran(IsolationLevel iso)
{ {
CheckConnection(); CheckConnection();
if (this.Transaction == null) if (this.Transaction == null)
this.Transaction = this.Connection.BeginTransaction(iso); this.Transaction = this.Connection.BeginTransaction(iso);
} }
public virtual async Task BeginTranAsync(IsolationLevel iso)
{
await CheckConnectionAsync();
if (this.Transaction == null)
this.Transaction =await (this.Connection as DbConnection).BeginTransactionAsync(iso);
}
public virtual void RollbackTran() public virtual void RollbackTran()
{ {
if (this.Transaction != null) if (this.Transaction != null)

18
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs

@ -562,6 +562,7 @@ namespace SqlSugar
queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex; queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex;
CheckHasRootShortName(method.Arguments[0], method.Arguments[1]); CheckHasRootShortName(method.Arguments[0], method.Arguments[1]);
var exp = method.Arguments[1]; var exp = method.Arguments[1];
InitMappingtType(exp);
where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString()); where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
SetTableShortName(result, queryable); SetTableShortName(result, queryable);
parameterIndex=queryable.QueryBuilder.LambdaExpressions.ParameterIndex ; parameterIndex=queryable.QueryBuilder.LambdaExpressions.ParameterIndex ;
@ -574,6 +575,7 @@ namespace SqlSugar
{ {
queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex; queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex;
var exp = method.Arguments[2]; var exp = method.Arguments[2];
InitMappingtType(exp);
CheckHasRootShortName(method.Arguments[1], method.Arguments[2]); CheckHasRootShortName(method.Arguments[1], method.Arguments[2]);
where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString()); where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
SetTableShortName(result, queryable); SetTableShortName(result, queryable);
@ -796,5 +798,21 @@ namespace SqlSugar
return shortName; return shortName;
} }
private void InitMappingtType(Expression exp)
{
if (exp is LambdaExpression)
{
var pars = (exp as LambdaExpression).Parameters;
if (pars != null)
{
foreach (var item in pars)
{
this.Context.InitMappingInfo(item.Type);
}
}
}
}
} }
} }

Loading…
Cancel
Save