Allows you to dynamically composing expression predicates to be used in WHERE clauses in LINQ and also in EntityFramework.
Questions tagged [predicatebuilder]
241 questions
1
vote
2 answers
Linq to XML Get parent element attribute value by querying it's children
I'm trying to build a Linq to XML Query but havent found a real solution yet.
Here is my XML
…

Michael D. Irizarry
- 6,186
- 5
- 30
- 35
1
vote
1 answer
Entity Framework Using Predicates Issue
I am using predicates to refine search options and am getting two different results when i run what looks to be the same query.
This one is correct and returns the expected results:(hard coded strings)
_predicate =…

Billy Logan
- 2,833
- 16
- 43
- 49
1
vote
1 answer
Entity Framework using Predicates
I am in the process of building out a search that requires the use of predicates. However, whenever i run the below query i continue to get only the results of the last predicate. The results from the first are not included. Based off my query…

Billy Logan
- 2,833
- 16
- 43
- 49
1
vote
2 answers
using .Equals() failing in Predicatebuilder
Hi I am using Predicate builder to build up my where clause.
I noticed that it was doing a case sensitive comparison against the entity datasource. Some quick googling implies this is a feature of linqtoentities. so i have had to modify my code to…

Tim
- 7,401
- 13
- 61
- 102
1
vote
3 answers
Shorter Way To Write Expression Trees with Predicate Builder
Is there an easier way to write the expression trees with Predicate Builder. It just seems like a lot of code that can be condensed.
Expression> gymCourt = q => q.GymCourt;
Expression> gym = q…

Mike Flynn
- 22,342
- 54
- 182
- 341
1
vote
0 answers
LinqToSql PredicateBuilder How to retrieve the last inserted value
I have two tables
Table Products
-ID
-Name
-Description
...
And
Table Price
-ProductID
-Price
-DateAdded
How do I create a Predicate which we will return the list of products whose price is greater than 10
I tried the following query
Dim…

SelvirK
- 925
- 3
- 18
- 42
1
vote
2 answers
how do you split up or join a linq query on an "or" (without using Union)?
Suppose you're searching some object with two boolean properties, A and B.
What if you have two linq queries:
IQueryable query = getIQueryableSomehow()
query.Where(x => x.A);
IQueryable query2 =…

Isaac Bolinger
- 7,328
- 11
- 52
- 90
1
vote
2 answers
PredicateBuilder with navigation properties and multiple conditions
I'm using the PredicateBuilder in the LinqKit to dynamically form the Where expression. When either LastName or FirstName from the SearchCriteria is populated then the SQL statement works correctly. However when both FirstName and LastName are…

Andy
- 13
- 4
1
vote
0 answers
PredicateBuilder null check not added to query
I have a situation where I want to query an accounts table. I want all accounts except accounts where ParentId != null as default.
I have tried the following with the predicate builder, but it does not take effect in the sql query. Any idea how to…

IceCode
- 1,466
- 13
- 22
1
vote
1 answer
dynamically append multiple linq expressions at run-time
I have two similar methods that take a criteria object (dumb object with a list of properties), call a "CreateExpression" method on that criteria object, and then use the returned expression to filter results.
One of my examples has an argument of…

Amanda Kitson
- 5,477
- 12
- 49
- 73
1
vote
1 answer
Problem with dynamic query building for Entity Framework Core 3.1.6
I am building LINQ queries dynamically. I use EF Core 3.1.6 (for SQL Server).
I create an IQueryable with a where() clause using a predicate.
EF Core is able to translate the following predicate expression and the query works as expected:
{p =>…

Humayun Khan
- 63
- 1
- 5
1
vote
2 answers
How to pass a runtime parameter to an EF Core predicate expression
In an app the uses EF Core, I am attempting to eliminate duplication of query code by creating a reusable library of predicate expressions. However, I am struggling with predicates that accept runtime parameters.
Let's assume 2 simple entity classes…

Tim Coulter
- 8,705
- 11
- 64
- 95
1
vote
1 answer
How to convert LambdaExpression to Expression> in C#
I have the below code that generates LambdaExpression at run time based on my SearchTerm inputs. I'm trying to build a dynamic where clause. However I'm stuck at how to convert from LambdaExpression to Expression>
private static…

fingers10
- 6,675
- 10
- 49
- 87
1
vote
1 answer
Design Patterns or good ideas for organizing a massive library of predicates
I have written/am writing a large number of predicates for testing the state of a single complex entity. These predicates are partially LINQ queries (that I assume are turned into SQL) and partially C# lambda/methods used to verify the state of the…

RBZ
- 2,034
- 17
- 34
1
vote
2 answers
Extract Objects from Collection based on a Map input
I have a collection of around 13360 Account objects, something like below
Input…

user2833621
- 165
- 1
- 13