Browse Source

Synchronization code

pull/32/head
sunkaixuan 2 years ago
parent
commit
a240c1f9bf
  1. 1
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs
  2. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionOutParameter.cs
  3. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Item.cs
  4. 6
      Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs

1
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

@ -973,6 +973,7 @@ namespace SqlSugar
public bool NoCheckInclude { get; set; } public bool NoCheckInclude { get; set; }
public virtual bool IsSelectNoAll { get; set; } = false; public virtual bool IsSelectNoAll { get; set; } = false;
public List<string> AutoAppendedColumns { get; set; } public List<string> AutoAppendedColumns { get; set; }
public Dictionary<string, string> MappingKeys { get; set; }
#endregion #endregion
private string GetTableName(string entityName) private string GetTableName(string entityName)

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionOutParameter.cs

@ -9,6 +9,6 @@ namespace SqlSugar
public class ExpressionOutParameter public class ExpressionOutParameter
{ {
public SqlSugarProvider Context { get; set; } public SqlSugarProvider Context { get; set; }
public QueryBuilder QueryBuilder { get; set; } public QueryBuilder QueryBuilder { get; set; }
} }
} }

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Item.cs

@ -122,14 +122,12 @@ namespace SqlSugar
mappingKeys.Add("Single_" + newExpressionInfo.LeftNameName, asName + "." + newExpressionInfo.LeftNameName); mappingKeys.Add("Single_" + newExpressionInfo.LeftNameName, asName + "." + newExpressionInfo.LeftNameName);
if (newExpressionInfo.Type == nameof(ConstantExpression)) if (newExpressionInfo.Type == nameof(ConstantExpression))
{ {
CallContextThread<Dictionary<string, string>>.SetData("Exp_Select_Mapping_Key", mappingKeys); this.Context.SugarContext.QueryBuilder.MappingKeys = mappingKeys;
CallContextAsync<Dictionary<string, string>>.SetData("Exp_Select_Mapping_Key", mappingKeys);
parameter.Context.Result.Append($" {newExpressionInfo.RightDbName} AS {this.Context.SqlTranslationLeft}{asName}.{newExpressionInfo.LeftNameName}{this.Context.SqlTranslationRight} "); parameter.Context.Result.Append($" {newExpressionInfo.RightDbName} AS {this.Context.SqlTranslationLeft}{asName}.{newExpressionInfo.LeftNameName}{this.Context.SqlTranslationRight} ");
} }
else else
{ {
CallContextThread<Dictionary<string, string>>.SetData("Exp_Select_Mapping_Key", mappingKeys); this.Context.SugarContext.QueryBuilder.MappingKeys = mappingKeys;
CallContextAsync<Dictionary<string, string>>.SetData("Exp_Select_Mapping_Key", mappingKeys);
parameter.Context.Result.Append(this.Context.GetAsString( parameter.Context.Result.Append(this.Context.GetAsString(
this.Context.SqlTranslationLeft + asName + "." + newExpressionInfo.LeftNameName + this.Context.SqlTranslationRight, this.Context.SqlTranslationLeft + asName + "." + newExpressionInfo.LeftNameName + this.Context.SqlTranslationRight,
newExpressionInfo.RightDbName newExpressionInfo.RightDbName

6
Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs

@ -368,11 +368,7 @@ namespace SqlSugar
private Dictionary<string, object> DataReaderToList<T>(IDataReader reader, Type tType, List<PropertyInfo> classProperties, List<T> reval) private Dictionary<string, object> DataReaderToList<T>(IDataReader reader, Type tType, List<PropertyInfo> classProperties, List<T> reval)
{ {
var readerValues = DataReaderToDictionary(reader, tType); var readerValues = DataReaderToDictionary(reader, tType);
var mappingKeys = CallContextThread<Dictionary<string, string>>.GetData("Exp_Select_Mapping_Key"); var mappingKeys = this.QueryBuilder.MappingKeys;
if (mappingKeys == null)
{
mappingKeys = CallContextAsync<Dictionary<string, string>>.GetData("Exp_Select_Mapping_Key");
}
var result = new Dictionary<string, object>(); var result = new Dictionary<string, object>();
foreach (var item in classProperties) foreach (var item in classProperties)
{ {

Loading…
Cancel
Save