2018-04-05 18:54:28 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2018-04-05 20:28:07 -04:00
|
|
|
|
using System.Linq;
|
2018-04-05 18:54:28 -04:00
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace PoweredSoft.DynamicLinq.Parser
|
|
|
|
|
{
|
|
|
|
|
public static class ParserExtensions
|
|
|
|
|
{
|
|
|
|
|
public static ExpressionParserPiece FirstEnumerableParent(this ExpressionParserPiece piece)
|
|
|
|
|
{
|
|
|
|
|
var result = ExpressionParser.GetFirstEnumerableParent(piece);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 20:28:07 -04:00
|
|
|
|
public static Expression CompileGroup(this ExpressionParserPieceGroup group, SelectNullHandling NullHandling)
|
2018-04-05 18:54:28 -04:00
|
|
|
|
{
|
2018-04-05 20:28:07 -04:00
|
|
|
|
var expr = group.Parameter as Expression;
|
2018-04-05 18:54:28 -04:00
|
|
|
|
group.Pieces.ForEach(piece =>
|
|
|
|
|
{
|
|
|
|
|
expr = Expression.PropertyOrField(expr, piece.Name);
|
|
|
|
|
});
|
2018-04-05 20:28:07 -04:00
|
|
|
|
return expr;
|
|
|
|
|
}
|
2018-04-05 18:54:28 -04:00
|
|
|
|
|
2018-04-05 20:28:07 -04:00
|
|
|
|
public static Type GroupEnumerableType(this ExpressionParserPieceGroup group)
|
|
|
|
|
{
|
|
|
|
|
return group.Pieces.Last().EnumerableType;
|
2018-04-05 18:54:28 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|