advancing but not there yet.

This commit is contained in:
David Lebee 2018-03-22 23:34:46 -05:00
parent 9f7e8bfc4e
commit 406290df78
3 changed files with 14 additions and 4 deletions

View File

@ -82,11 +82,15 @@ namespace PoweredSoft.DynamicLinq.Test
{
var query = TestData.Authors.AsQueryable();
query.Select(t => new
var qs = query.Select(t => new
{
Comments = t.Posts == null ? null : t.Posts.SelectMany(t2 => t2.Comments).ToList()
CommentLikes = t.Posts == null ?
new List<CommentLike>() :
t.Posts.Where(t2 => t2.Comments != null).SelectMany(t2 => t2.Comments.Where(t3 => t3.CommentLikes != null).SelectMany(t3 => t3.CommentLikes)).ToList()
});
var a = qs.ToList();
var querySelect = query.Select(t =>
{
t.NullChecking(true);

View File

@ -168,6 +168,12 @@ namespace PoweredSoft.DynamicLinq.Test
Content = "ASD"
}
}
},
new Author
{
Id = 3,
FirstName = "Mark",
LastName = "Ronson"
}
};
}

View File

@ -213,8 +213,8 @@ namespace PoweredSoft.DynamicLinq.Helpers
var notGroupedType = expr.Type.GenericTypeArguments.FirstOrDefault();
if (notGroupedType == null)
throw new Exception($"Path must be a Enumerable<T> but its a {expr.Type}");
var body = Expression.Call(typeof(Enumerable), "ToList", new[] { notGroupedType }, expr);
var body = Expression.Call(typeof(Enumerable), "ToList", new[] { notGroupedType }, expr) as Expression;
return body;
}