- 增加 IncludeMany 贪婪加载的时候可指定子表的字段,避免查询子表所有字段;

This commit is contained in:
28810
2019-11-18 03:22:34 +08:00
parent 769c1f020c
commit 1083f371a9
16 changed files with 1899 additions and 343 deletions

View File

@@ -108,31 +108,34 @@ namespace FreeSql.Internal
parent.Consturctor = initExp.NewExpression.Type.GetConstructors()[0];
parent.ConsturctorType = ReadAnonymousTypeInfoConsturctorType.Properties;
//dto 映射
var dtoProps = initExp.NewExpression.Type.GetPropertiesDictIgnoreCase().Values;
foreach (var dtoProp in dtoProps)
if (initExp.NewExpression.Type != _tables.FirstOrDefault()?.Table.Type)
{
foreach (var dtTb in _tables)
//dto 映射
var dtoProps = initExp.NewExpression.Type.GetPropertiesDictIgnoreCase().Values;
foreach (var dtoProp in dtoProps)
{
if (dtTb.Table.Columns.TryGetValue(dtoProp.Name, out var trydtocol))
foreach (var dtTb in _tables)
{
var child = new ReadAnonymousTypeInfo
if (dtTb.Table.Columns.TryGetValue(dtoProp.Name, out var trydtocol))
{
Property = dtoProp,
CsName = dtoProp.Name,
CsType = dtoProp.PropertyType,
MapType = trydtocol.Attribute.MapType
};
parent.Childs.Add(child);
if (dtTb.Parameter != null)
ReadAnonymousField(_tables, field, child, ref index, Expression.Property(dtTb.Parameter, dtTb.Table.Properties[trydtocol.CsName]), getSelectGroupingMapString, whereCascadeExpression);
else
{
child.DbField = $"{dtTb.Alias}.{_common.QuoteSqlName(trydtocol.Attribute.Name)}";
field.Append(", ").Append(child.DbField);
if (index >= 0) field.Append(" as").Append(++index);
var child = new ReadAnonymousTypeInfo
{
Property = dtoProp,
CsName = dtoProp.Name,
CsType = dtoProp.PropertyType,
MapType = trydtocol.Attribute.MapType
};
parent.Childs.Add(child);
if (dtTb.Parameter != null)
ReadAnonymousField(_tables, field, child, ref index, Expression.Property(dtTb.Parameter, dtTb.Table.Properties[trydtocol.CsName]), getSelectGroupingMapString, whereCascadeExpression);
else
{
child.DbField = $"{dtTb.Alias}.{_common.QuoteSqlName(trydtocol.Attribute.Name)}";
field.Append(", ").Append(child.DbField);
if (index >= 0) field.Append(" as").Append(++index);
}
break;
}
break;
}
}
}