advancing well to be continued.
This commit is contained in:
parent
13576133b5
commit
2bd292f18d
@ -44,7 +44,7 @@ namespace PoweredSoft.DynamicLinq.ConsoleApp
|
|||||||
public static void Case2()
|
public static void Case2()
|
||||||
{
|
{
|
||||||
// the expression parser.
|
// the expression parser.
|
||||||
var ep = new ExpressionParser(typeof(Post), "Author.Posts.Author.FirstName");
|
var ep = new ExpressionParser(typeof(Post), "Author.Posts.Author.Posts.Author.FirstName");
|
||||||
|
|
||||||
new List<Post>().AsQueryable().Select(t => new
|
new List<Post>().AsQueryable().Select(t => new
|
||||||
{
|
{
|
||||||
@ -111,8 +111,8 @@ namespace PoweredSoft.DynamicLinq.ConsoleApp
|
|||||||
}
|
}
|
||||||
else if (piece.Parent.IsGenericEnumerable)
|
else if (piece.Parent.IsGenericEnumerable)
|
||||||
{
|
{
|
||||||
var indexOfPiece = Parser.Pieces.IndexOf(piece);
|
var indexOfParentPiece = Parser.Pieces.IndexOf(piece);
|
||||||
var currentSimpleChain = Parser.Pieces.Skip(indexOfPiece - 1).Where(t => !t.IsGenericEnumerable).ToList();
|
var currentSimpleChain = Parser.Pieces.Skip(indexOfParentPiece).TakeWhile(t => !t.IsGenericEnumerable).ToList();
|
||||||
var parameter = ResolveParameter(currentSimpleChain);
|
var parameter = ResolveParameter(currentSimpleChain);
|
||||||
var currentSimpleChainExpression = BuildSimpleChainExpression(currentSimpleChain, parameter);
|
var currentSimpleChainExpression = BuildSimpleChainExpression(currentSimpleChain, parameter);
|
||||||
var currentSimpleChainExpressionLambda = Expression.Lambda(currentSimpleChainExpression, parameter);
|
var currentSimpleChainExpressionLambda = Expression.Lambda(currentSimpleChainExpression, parameter);
|
||||||
@ -121,24 +121,24 @@ namespace PoweredSoft.DynamicLinq.ConsoleApp
|
|||||||
var left = RecursiveSelect(piece.Parent);
|
var left = RecursiveSelect(piece.Parent);
|
||||||
|
|
||||||
// the parent.
|
// the parent.
|
||||||
var parent = Expression.PropertyOrField(left, piece.Parent.Name) as Expression;
|
var parentExpression = Expression.PropertyOrField(left, piece.Parent.Name) as Expression;
|
||||||
|
|
||||||
if (NullChecking != SelectNullHandling.LeaveAsIs)
|
if (NullChecking != SelectNullHandling.LeaveAsIs)
|
||||||
{
|
{
|
||||||
var nullCheckParameter = ResolveParameter(currentSimpleChain);
|
var nullCheckParameter = ResolveParameter(currentSimpleChain);
|
||||||
var nullCheckConditionExpression = BuildNullCheckConditionExpression(currentSimpleChain, nullCheckParameter);
|
var nullCheckConditionExpression = BuildNullCheckConditionExpression(currentSimpleChain, nullCheckParameter);
|
||||||
var whereExpression = Expression.Call(typeof(Enumerable), "Where", new[] { piece.Parent.EnumerableType }, parent, nullCheckConditionExpression);
|
var whereExpression = Expression.Call(typeof(Enumerable), "Where", new[] { piece.Parent.EnumerableType }, parentExpression, nullCheckConditionExpression);
|
||||||
parent = whereExpression as Expression;
|
parentExpression = whereExpression as Expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
// select.
|
// select.
|
||||||
var allPiecesAttached = Expression.Call(typeof(Enumerable),
|
var gluedTogetherExpression = Expression.Call(typeof(Enumerable),
|
||||||
"Select",
|
"Select",
|
||||||
new Type[] { piece.Parent.EnumerableType, currentSimpleChainExpression.Type },
|
new Type[] { piece.Parent.EnumerableType, currentSimpleChainExpression.Type },
|
||||||
parent, currentSimpleChainExpressionLambda);
|
parentExpression, currentSimpleChainExpressionLambda);
|
||||||
|
|
||||||
// add current to parent?
|
// add current to parent?
|
||||||
return allPiecesAttached;
|
return gluedTogetherExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip.
|
// skip.
|
||||||
|
Loading…
Reference in New Issue
Block a user