better unit test to test grouping.

This commit is contained in:
David Lebée
2018-03-14 20:08:17 -05:00
parent ed88de7c02
commit 9fe85fcb65
2 changed files with 42 additions and 68 deletions
@@ -11,8 +11,8 @@ namespace PoweredSoft.DynamicLinq
{
public static class QueryableExtensions
{
public static IQueryable<T> Where<T>(this IQueryable<T> query, string path, ConditionOperators conditionOperator, object value,
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
public static IQueryable<T> Where<T>(this IQueryable<T> query, string path, ConditionOperators conditionOperator, object value,
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
{
query = query.Query(qb => qb.Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision));
@@ -22,7 +22,7 @@ namespace PoweredSoft.DynamicLinq
public static IQueryable<T> Where<T>(this IQueryable<T> query, Action<WhereBuilder> callback)
=> query.Query(callback);
public static IQueryable<T> Query<T> (this IQueryable<T> query, Action<WhereBuilder> callback)
public static IQueryable<T> Query<T>(this IQueryable<T> query, Action<WhereBuilder> callback)
{
var queryBuilder = new WhereBuilder(query);
callback(queryBuilder);
@@ -115,5 +115,13 @@ namespace PoweredSoft.DynamicLinq
return ret;
}
public static List<DynamicClass> ToDynamicClassList(this IQueryable query)
{
if (!typeof(DynamicClass).IsAssignableFrom(query.ElementType))
throw new Exception($"{query.ElementType} does not inherit DynamicClass");
var ret = query.Cast<DynamicClass>().ToList();
return ret;
}
}
}