select many support for flattening.
This commit is contained in:
parent
0e7aca052c
commit
e961c38c99
@ -66,11 +66,22 @@ namespace PoweredSoft.DynamicLinq.Resolver
|
|||||||
parentExpression = CheckNullOnEnumerableParent(group, parent, parentExpression, isLastGroup);
|
parentExpression = CheckNullOnEnumerableParent(group, parent, parentExpression, isLastGroup);
|
||||||
|
|
||||||
// the select expression.
|
// the select expression.
|
||||||
var selectType = parent.GroupEnumerableType();
|
if (CollectionHandling == SelectCollectionHandling.Flatten && QueryableHelpers.IsGenericEnumerable(groupExpression))
|
||||||
var selectExpression = Expression.Call(typeof(Enumerable), "Select",
|
{
|
||||||
new Type[] { selectType, groupExpression.Type },
|
var selectType = parent.GroupEnumerableType();
|
||||||
parentExpression, groupExpressionLambda);
|
var selectExpression = Expression.Call(typeof(Enumerable), "SelectMany",
|
||||||
currentExpression = selectExpression;
|
new Type[] { selectType, groupExpression.Type.GenericTypeArguments.First() },
|
||||||
|
parentExpression, groupExpressionLambda);
|
||||||
|
currentExpression = selectExpression;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var selectType = parent.GroupEnumerableType();
|
||||||
|
var selectExpression = Expression.Call(typeof(Enumerable), "Select",
|
||||||
|
new Type[] { selectType, groupExpression.Type },
|
||||||
|
parentExpression, groupExpressionLambda);
|
||||||
|
currentExpression = selectExpression;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -91,10 +102,20 @@ namespace PoweredSoft.DynamicLinq.Resolver
|
|||||||
if (NullChecking != false)
|
if (NullChecking != false)
|
||||||
parentExpression = CheckNullOnEnumerableParent(group, parent, parentExpression, isLastGroup);
|
parentExpression = CheckNullOnEnumerableParent(group, parent, parentExpression, isLastGroup);
|
||||||
|
|
||||||
var currentExpressionLambda = Expression.Lambda(currentExpression, group.Parameter);
|
if (CollectionHandling == SelectCollectionHandling.Flatten && QueryableHelpers.IsGenericEnumerable(currentExpression))
|
||||||
currentExpression = Expression.Call(typeof(Enumerable), "Select",
|
{
|
||||||
new Type[] { selectType, currentExpression.Type },
|
var currentExpressionLambda = Expression.Lambda(currentExpression, group.Parameter);
|
||||||
parentExpression, currentExpressionLambda);
|
currentExpression = Expression.Call(typeof(Enumerable), "SelectMany",
|
||||||
|
new Type[] { selectType, currentExpression.Type.GenericTypeArguments.First() },
|
||||||
|
parentExpression, currentExpressionLambda);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var currentExpressionLambda = Expression.Lambda(currentExpression, group.Parameter);
|
||||||
|
currentExpression = Expression.Call(typeof(Enumerable), "Select",
|
||||||
|
new Type[] { selectType, currentExpression.Type },
|
||||||
|
parentExpression, currentExpressionLambda);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user