select many support for flattening.
This commit is contained in:
parent
0e7aca052c
commit
e961c38c99
@ -66,12 +66,23 @@ namespace PoweredSoft.DynamicLinq.Resolver
|
||||
parentExpression = CheckNullOnEnumerableParent(group, parent, parentExpression, isLastGroup);
|
||||
|
||||
// the select expression.
|
||||
if (CollectionHandling == SelectCollectionHandling.Flatten && QueryableHelpers.IsGenericEnumerable(groupExpression))
|
||||
{
|
||||
var selectType = parent.GroupEnumerableType();
|
||||
var selectExpression = Expression.Call(typeof(Enumerable), "SelectMany",
|
||||
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
|
||||
{
|
||||
if (group.Parent == null)
|
||||
@ -91,12 +102,22 @@ namespace PoweredSoft.DynamicLinq.Resolver
|
||||
if (NullChecking != false)
|
||||
parentExpression = CheckNullOnEnumerableParent(group, parent, parentExpression, isLastGroup);
|
||||
|
||||
if (CollectionHandling == SelectCollectionHandling.Flatten && QueryableHelpers.IsGenericEnumerable(currentExpression))
|
||||
{
|
||||
var currentExpressionLambda = Expression.Lambda(currentExpression, group.Parameter);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Result = currentExpression;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user