one step closer.

This commit is contained in:
David Lebee 2018-03-27 19:37:19 -05:00
parent 1a4bde89df
commit 48db853236
2 changed files with 14 additions and 5 deletions

View File

@ -23,7 +23,7 @@ namespace PoweredSoft.DynamicLinq.ConsoleApp
var expressionParser = new ExpressionParser(typeof(Author), "Posts.Comments.CommentLikes"); var expressionParser = new ExpressionParser(typeof(Author), "Posts.Comments.CommentLikes");
expressionParser.Parse(); expressionParser.Parse();
var finalExpression = CreateSelectExpressionFromParsed(expressionParser, SelectCollectionHandling.Flatten, SelectNullHandling.LeaveAsIs); var finalExpression = CreateSelectExpressionFromParsed(expressionParser, SelectCollectionHandling.Flatten, SelectNullHandling.New);
} }
public static Expression CreateSelectExpressionFromParsed(ExpressionParser expressionParser, public static Expression CreateSelectExpressionFromParsed(ExpressionParser expressionParser,
@ -32,15 +32,19 @@ namespace PoweredSoft.DynamicLinq.ConsoleApp
{ {
Type nullHandlingRightType = null; Type nullHandlingRightType = null;
Expression nullHandlingNullValue = null; Expression nullHandlingNullValue = null;
/*
if (nullChecking != SelectNullHandling.LeaveAsIs) if (nullChecking != SelectNullHandling.LeaveAsIs)
{ {
nullHandlingRightType = parts.Last().PartExpression.Type; var withoutNullCheckResult = CreateSelectExpressionFromParsed(expressionParser, SelectCollectionHandling.Flatten, SelectNullHandling.LeaveAsIs);
if (QueryableHelpers.IsGenericEnumerable(withoutNullCheckResult.Type))
nullHandlingRightType = typeof(List<>).MakeGenericType(withoutNullCheckResult.Type.GenericTypeArguments.First());
else
nullHandlingRightType = withoutNullCheckResult.Type;
nullHandlingNullValue = nullChecking == SelectNullHandling.Default nullHandlingNullValue = nullChecking == SelectNullHandling.Default
? Expression.Default(nullHandlingRightType) as Expression ? Expression.Default(nullHandlingRightType) as Expression
: Expression.New(nullHandlingRightType) as Expression; : Expression.New(nullHandlingRightType) as Expression;
}*/ }
// reversed :) // reversed :)
var reversedCopy = expressionParser.Groups.Select(t => t).ToList(); var reversedCopy = expressionParser.Groups.Select(t => t).ToList();

View File

@ -122,6 +122,11 @@ namespace PoweredSoft.DynamicLinq.Helpers
Groups.Add(group); Groups.Add(group);
return group; return group;
} }
public ExpressionParameterGroup LastGroup()
{
return this.Groups.Last();
}
} }
public class ExpressionPathPart public class ExpressionPathPart