Optimize the code

This commit is contained in:
sunkaixuan 2025-06-07 20:18:54 +08:00
parent 4eb4165ef9
commit 48e656f60b
3 changed files with 13 additions and 26 deletions

View File

@ -55,6 +55,19 @@ namespace SqlSugar
protected void ResolveNewExpressions(ExpressionParameter parameter, Expression item, string asName)
{
if (item is ParameterExpression)
{
var itemType = item.Type;
var ignoreProperty = itemType.GetProperties().FirstOrDefault(it => it.PropertyType == itemType);
if (ignoreProperty != null && ignoreProperty.Name != asName)
{
if (this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns == null)
{
this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns = new List<KeyValuePair<string, string>>();
}
this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns.Add(new KeyValuePair<string, string>(ignoreProperty.Name, itemType.Name));
}
}
if (item is ConstantExpression)
{
ResolveConst(parameter, item, asName);

View File

@ -356,19 +356,6 @@ namespace SqlSugar
item = (item as UnaryExpression).Operand;
}
}
if (item is ParameterExpression)
{
var itemType = item.Type;
var ignoreProperty = itemType.GetProperties().FirstOrDefault(it => it.PropertyType == itemType);
if (ignoreProperty != null && ignoreProperty.Name != memberName)
{
if (this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns == null)
{
this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns = new List<KeyValuePair<string, string>>();
}
this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns.Add(new KeyValuePair<string, string>(ignoreProperty.Name, itemType.Name));
}
}
ResolveNewExpressions(parameter, item, memberName);
}
}

View File

@ -158,19 +158,6 @@ namespace SqlSugar
continue;
}
++i;
if (item is ParameterExpression)
{
var itemType = item.Type;
var ignoreProperty = itemType.GetProperties().FirstOrDefault(it => it.PropertyType == itemType);
if (ignoreProperty!=null&& ignoreProperty.Name!=memberName)
{
if (this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns == null)
{
this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns = new List<KeyValuePair<string, string>>();
}
this.Context.SugarContext.QueryBuilder.SelectNewIgnoreColumns.Add(new KeyValuePair<string, string>(ignoreProperty.Name, itemType.Name));
}
}
ResolveNewExpressions(parameter, item, memberName);
}
}