flattening support on wrap select.
This commit is contained in:
parent
aba20f04e2
commit
a7937cd500
@ -9,6 +9,7 @@ using PoweredSoft.DynamicLinq.Dal;
|
||||
using System.Diagnostics;
|
||||
using PoweredSoft.DynamicLinq.Test.Helpers;
|
||||
using System.Collections;
|
||||
using PoweredSoft.DynamicLinq.Dal.Pocos;
|
||||
|
||||
namespace PoweredSoft.DynamicLinq.Test
|
||||
{
|
||||
@ -289,7 +290,7 @@ namespace PoweredSoft.DynamicLinq.Test
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GroupByToListWithPathWithNullChecking()
|
||||
public void GroupByToListWithPathWithNullCheckingWithFlattening()
|
||||
{
|
||||
var limitResult = TestData.Authors;
|
||||
|
||||
@ -300,7 +301,7 @@ namespace PoweredSoft.DynamicLinq.Test
|
||||
.Select(t => new
|
||||
{
|
||||
Key = t.Key.AuthorFirstName,
|
||||
Contents = t.SelectMany(t2 => t2.Posts.Select(t3 => t3.Content)).ToList()
|
||||
Contents = t.SelectMany(t2 => t2.Posts == null ? new List<string>() : t2.Posts.Select(t3 => t3.Content)).ToList()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
@ -220,10 +220,16 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
||||
{
|
||||
var selectType = parameter.Type.GenericTypeArguments.Skip(1).First();
|
||||
var innerSelectType = ((LambdaExpression)innerLambdaExpression).ReturnType;
|
||||
var selectExpression = Expression.Call(typeof(Enumerable), "Select", new Type[] { selectType, innerSelectType }, parameter, innerLambdaExpression);
|
||||
|
||||
Expression selectExpression;
|
||||
if (QueryableHelpers.IsGenericEnumerable(innerSelectType) && selectCollectionHandling == SelectCollectionHandling.Flatten)
|
||||
selectExpression = Expression.Call(typeof(Enumerable), "SelectMany", new Type[] { selectType, innerSelectType.GenericTypeArguments.First() }, parameter, innerLambdaExpression);
|
||||
else
|
||||
selectExpression = Expression.Call(typeof(Enumerable), "Select", new Type[] { selectType, innerSelectType }, parameter, innerLambdaExpression);
|
||||
|
||||
return selectExpression;
|
||||
}
|
||||
|
||||
|
||||
private static Expression CreateSelectExpression(IQueryable query, ParameterExpression parameter, SelectTypes selectType, string path, SelectCollectionHandling selectCollectionHandling, bool nullChecking)
|
||||
{
|
||||
if (!IsGrouping(query))
|
||||
|
@ -1,12 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DynamicLinq.Helpers
|
||||
{
|
||||
|
||||
public static class QueryablePathHelpers
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user