adding extension method straight on where.

This commit is contained in:
David Lebée 2018-03-07 20:16:15 -06:00
parent 74a68c70c1
commit fce55178bb
4 changed files with 19 additions and 2 deletions

View File

@ -30,5 +30,11 @@ namespace PoweredSoft.DynamicLinq.EntityFramework
query = query.Query(callback); query = query.Query(callback);
return query; return query;
} }
public static IQueryable Where(this DbContext context, Type pocoType, Action<QueryBuilderBase> callback)
=> context.Query(pocoType, callback);
public static IQueryable<T> Where<T>(this DbContext context, Action<QueryBuilderBase> callback)
where T : class => context.Query<T>(callback);
} }
} }

View File

@ -112,7 +112,14 @@ namespace PoweredSoft.DynamicLinq.Test
qb.And("Posts.Comments.Email", ConditionOperators.Equal, "john.doe@me.com", collectionHandling: QueryCollectionHandling.Any); qb.And("Posts.Comments.Email", ConditionOperators.Equal, "john.doe@me.com", collectionHandling: QueryCollectionHandling.Any);
}); });
var query2 = query.Where(qb =>
{
qb.NullChecking();
qb.And("Posts.Comments.Email", ConditionOperators.Equal, "john.doe@me.com", collectionHandling: QueryCollectionHandling.Any);
});
Assert.AreEqual(1, query.Count()); Assert.AreEqual(1, query.Count());
Assert.AreEqual(1, query2.Count());
} }
} }

View File

@ -13,6 +13,9 @@ namespace PoweredSoft.DynamicLinq
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null) QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
=> list.AsQueryable().Where(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision); => list.AsQueryable().Where(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
public static IEnumerable<T> Where<T>(this IEnumerable<T> list, Action<QueryBuilder<T>> callback)
=> list.Query(callback);
public static IEnumerable<T> Query<T>(this IEnumerable<T> list, Action<QueryBuilder<T>> callback) public static IEnumerable<T> Query<T>(this IEnumerable<T> list, Action<QueryBuilder<T>> callback)
=> list.AsQueryable().Query(callback); => list.AsQueryable().Query(callback);

View File

@ -19,7 +19,8 @@ namespace PoweredSoft.DynamicLinq
return query; return query;
} }
public static IQueryable<T> Where<T>(this IQueryable<T> query, Action<QueryBuilder<T>> callback)
=> query.Query(callback);
public static IQueryable<T> Query<T> (this IQueryable<T> query, Action<QueryBuilder<T>> callback) public static IQueryable<T> Query<T> (this IQueryable<T> query, Action<QueryBuilder<T>> callback)
{ {