- 优化 dto 映射查询时忽略已指定的映射,避免重复查询字段;#494

This commit is contained in:
28810 2020-10-16 13:32:34 +08:00
parent b3f8c112f1
commit 935cd5ba8c

View File

@ -204,6 +204,7 @@ namespace FreeSql.Internal
} }
else if (isAllDtoMap && _tables != null && _tables.Any() && initExp.NewExpression.Type != _tables.FirstOrDefault().Table.Type) else if (isAllDtoMap && _tables != null && _tables.Any() && initExp.NewExpression.Type != _tables.FirstOrDefault().Table.Type)
{ {
var dicBindings = initExp.Bindings?.Select(a => a.Member.Name).Distinct().ToDictionary(a => a, a => false);
//dto 映射 //dto 映射
var dtoProps = initExp.NewExpression.Type.GetPropertiesDictIgnoreCase().Values; var dtoProps = initExp.NewExpression.Type.GetPropertiesDictIgnoreCase().Values;
foreach (var dtoProp in dtoProps) foreach (var dtoProp in dtoProps)
@ -212,6 +213,7 @@ namespace FreeSql.Internal
{ {
if (dtTb.Table.ColumnsByCs.TryGetValue(dtoProp.Name, out var trydtocol) == false) continue; if (dtTb.Table.ColumnsByCs.TryGetValue(dtoProp.Name, out var trydtocol) == false) continue;
if (trydtocol.Attribute.IsIgnore == true) continue; if (trydtocol.Attribute.IsIgnore == true) continue;
if (dicBindings?.ContainsKey(dtoProp.Name) == true) continue;
var child = new ReadAnonymousTypeInfo var child = new ReadAnonymousTypeInfo
{ {