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-10 20:00:40 -04:00
|
|
|
|
|
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
|
|
|
|
}
|
2018-04-05 20:40:33 -04:00
|
|
|
|
|
|
|
|
|
public static Type ResolveNullHandlingType(this List<ExpressionParserPieceGroup> groups)
|
|
|
|
|
{
|
|
|
|
|
if (groups.Count() == 1)
|
|
|
|
|
{
|
2018-04-10 20:29:43 -04:00
|
|
|
|
return groups.First().Pieces.Last().Type;
|
2018-04-05 20:40:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var type = groups.Last().Pieces.Last().Type;
|
|
|
|
|
return typeof(IEnumerable<>).MakeGenericType(type);
|
|
|
|
|
}
|
2018-04-05 18:54:28 -04:00
|
|
|
|
}
|
|
|
|
|
}
|