From 8e12db2198d2eb1aea7db7bcff2a0ddc38cc75b6 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 17 Jan 2023 16:21:35 +0800 Subject: [PATCH] Synchronization code --- .../Abstract/AdoProvider/AdoProvider.cs | 14 ++++++-------- .../QueryableProvider/NavigatManager.cs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs index a7aa7e32f..4918461ff 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs @@ -217,20 +217,18 @@ namespace SqlSugar if (this.Transaction == null) 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) { CheckConnection(); if (this.Transaction == null) 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() { if (this.Transaction != null) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs index 8f76f1f71..599d23968 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs @@ -562,6 +562,7 @@ namespace SqlSugar queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex; CheckHasRootShortName(method.Arguments[0], method.Arguments[1]); var exp = method.Arguments[1]; + InitMappingtType(exp); where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString()); SetTableShortName(result, queryable); parameterIndex=queryable.QueryBuilder.LambdaExpressions.ParameterIndex ; @@ -574,6 +575,7 @@ namespace SqlSugar { queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex; var exp = method.Arguments[2]; + InitMappingtType(exp); CheckHasRootShortName(method.Arguments[1], method.Arguments[2]); where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString()); SetTableShortName(result, queryable); @@ -796,5 +798,21 @@ namespace SqlSugar 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); + } + } + } + } + + } }