Allows you to dynamically composing expression predicates to be used in WHERE clauses in LINQ and also in EntityFramework.
Questions tagged [predicatebuilder]
241 questions
3
votes
2 answers
Sitecore Content Search PredicateBuilder vs IEnumerable
I'm having problem with querying IEnumerable computed index field. Im using Sitecore 7.2 upd2, Lucene, ContentSearch and PredicateBuilder.
I'm trying to query product prices which are available under products section. There is some heavy Logic to…

Bartek KG
- 41
- 4
3
votes
1 answer
PredicateBuilder stripping brackets, breaking nested AND's combined with OR
How can PredicateBuilder be used to OR together several statements with nested AND's, without stripping brackets?
We are trying to get:
(fieldA = X AND fieldB = Y AND fieldC = Z) or (fieldA = A AND fieldB = B and fieldC = C)
But the code below…

geoffreys
- 1,107
- 7
- 24
3
votes
2 answers
Is there a way to use PredicateBuilder with Azure Table Storage?
Just what it says on the tin, I have a design problem where normally PredicateBuilder would be the obvious answer, but when executing, I get errors such as :
The expression
((([10007].PartitionKey == "df2907ad-2094-4b7a-9796-d077f14b25bc")
And…

Jason Coyne
- 6,509
- 8
- 40
- 70
3
votes
1 answer
Apply PredicateBuilder to query a single object property of a list of items
Given the below sample models, I need to query the ITEMS by properties of its owner.
This is Entity Frameworks sets, and I want to do this using LINQ.
public class Owner
{
public int Id { get; set; }
public string Name { get; set; }
…

Romias
- 13,783
- 7
- 56
- 85
3
votes
2 answers
Comparing against child property in generic/dynamic linq predicate with reflection
I am having to generically build a comparative predicate for an Entity Framework Linq query. I'm using reflection and am able to build a single level Lambda expression without any trouble. However where I am starting to get stuck is I have an…

UnHoly Ram
- 157
- 1
- 9
3
votes
1 answer
Predicate Expression Function for repeated comparisons
I have a predicate handler that tests almost 200 cases, and each test involves five possible comparisons. I want to streamline this code, but am hitting a wall with how to express this syntactically.
public static…

Bob Jones
- 2,049
- 5
- 32
- 60
3
votes
0 answers
How to simplify composed predicates in LINQ to WCF Data Services?
I am using PredicateBuilder and Colin Meek's equivalent to compose predicates in an WCF Data Services friendly (i.e. no invocation expressions etc.) way. These work for some queries but fail with "Recursion reached allowed limit" as the query…

DazWilkin
- 32,823
- 5
- 47
- 88
3
votes
1 answer
PredicateBuilder reusable DateTime predicate setter
I'm using PredicateBuilder to generate dynamic search clauses. In the sample code below, is there a way that I can modify SetDateTimePredicate so it can be used for any DateTime property on SomeType?
Expression> somePredicate =…

user1360192
- 53
- 1
- 4
2
votes
2 answers
Nesting OR using Linq PredicateBuilder
I am using predicate builder to write the following code:
IEnumerable ids= new List { 47, 48 };
var predicate = PredicateBuilder.False();
predicate = predicate.And(x => x.CreatedAt >= fromDate && x.CreatedAt <=…

Thomas
- 5,888
- 7
- 44
- 83
2
votes
0 answers
PredicateBuilder/LINQ Encapsulate predicates, DI
I've started to notice that i my predicate building code looks similar. That's a sign to refactor it. Let's look at the code.
var predicate = PredicateBuilder.False();
// Under the covers it will get Guid from a cookie (one…

Auk
- 117
- 8
2
votes
1 answer
Linq PredicateBuilder
public static IQueryable FilterData(string Filter, Repository dc)
{
IQueryable data = null;
var predicate = PredicateBuilder.True();
Filter =…

user805661
- 51
- 1
- 3
2
votes
0 answers
Linq to Sql, PredicateBuilder and defining general logic
The examples with predicatebuilder show how you can define general logic using predicates. But I'm struggling with the following :
Suppose Product has a foreign key relationship with Category and Category has a DateTime? EndDate.
I can write some…

rekna
- 5,313
- 7
- 45
- 54
2
votes
0 answers
Entity Framework LinqKit dynamic where predicate over related data
The code is in Alpha version, don't have validations or error management ... It would be included later.
I have a very simple model with two related entities: Location and Country:
public class UNCountry
{
public int UNCountryId { get; set; }
…

Hermann
- 21
- 1
2
votes
1 answer
Count entity in Core Data with a specific Value
I have an Entity with some Attribute. I have my tabes already populates(SQLite table)
In one Attribute (i'll call Attribute1) i have a bool value, changing during use of my app.
How can i return the count of my Entities with Attribute1 value…

Elionline85
- 21
- 3
2
votes
1 answer
PredicateBuilder, VB.net and Where()
I am building a predicate in VB.net using the PredicateBuilder class from the LinqKit library.
My datasource is a manually constructed datatable.
All the examples I've found show folks creating the predicate and then passing that predicate as an…

Amanda Kitson
- 5,477
- 12
- 49
- 73