Allows you to dynamically composing expression predicates to be used in WHERE clauses in LINQ and also in EntityFramework.
Questions tagged [predicatebuilder]
241 questions
6
votes
1 answer
C# Predicate builder with using AND with OR
I have the following class:
public class testClass
{
public string name { get; set; }
public int id { get; set; }
public int age { get; set; }
}
and the following code:
var list = new List();
…

Alex
- 3,730
- 9
- 43
- 94
6
votes
2 answers
Building an Expression with an anonymous type
Let's say I've created some anonymous type via a LINQ query:
var query = from Person in db.People
join Pet in Pets on Person.ID equals Pet.PersonID
join Thingy in Thingies on Person.ID equals Thingy.PersonID
…

Mike Cluck
- 31,869
- 13
- 80
- 91
6
votes
4 answers
Why multiple filters are applied even if query recreated on each iteration
I found this code below in a file called Filter.cs in a project created with Microsoft App Studio. Although I am a veteran C# programmer, I'm short on experience with LINQ predicate expression builders. I can tell that the code below it is…

Robert Oschler
- 14,153
- 18
- 94
- 227
6
votes
2 answers
LinqKit PredicateBuilder returns all or non rows
I'm beginning to use LinqKit's PredicateBuilder to create predicate's with OR conditions which is not possible with Linq expressions.
The problem I'm facing is if I begin with PredicateBuilder.True() it returns all rows and if I begin with…

Ashkan
- 3,322
- 4
- 36
- 47
6
votes
1 answer
Need help in using PredicateBuilder
I need to know about using PredicateBuilder. On almost every example of how to use it, they show the code as follows:
var predicate = PredicateBuilder.True();
if (!string.IsNullOrEmpty(txtAddress.Text))
predicate = predicate.And(e1 =>…

Edgar Cohen
- 61
- 1
6
votes
1 answer
Unable to refactor using LINQ to Entities and LinqKit / PredicateBuilder
I have been trying to refactor a LINQ expression into a method, and have been running into both the "Internal .NET Framework Data Provider error 1025." and "The parameter 'xyz' was not bound in the specified LINQ to Entities query expression."…

danludwig
- 46,965
- 25
- 159
- 237
5
votes
2 answers
Trouble with using predicatebuilder in a foreach loop
I'm having trouble building predicates in a foreach loop. The variable that contains the value the enumerator is currently on is something I need to put in the predicate.
So,
IQueryable query = getIQueryableSomehow();
Predicate =…

Isaac Bolinger
- 7,328
- 11
- 52
- 90
5
votes
1 answer
LINQ PredicateBuilder multiple OR starting with PredicateBuilder.True<>
I have an entity like this:
public class Product()
{
public string Name { get; set; }
}
I want to implement a search for keywords on the Name property so that they're OR'ed. In other words, a search for:
spoon knife fork
will search for spoon…

Daniel T.
- 37,212
- 36
- 139
- 206
5
votes
1 answer
Adding Where Condition to All Requests EF6
Most of my entities (not all) have two properties called CompanyId and Deleted. How would be possible to auto insert these two properties for all select requests instead of setting manually on every single query I have along the whole…

Rubens Mussi Cury
- 508
- 4
- 16
5
votes
3 answers
How to check if predicate expression was changed?
var predicate = PredicateBuilder.True();
This is my predicate expression, where on some certain conditions I will append expressions with it.
Likewise
if (!string.IsNullOrEmpty(param.sSearch))
predicate = predicate.And(s…

Manoz
- 6,507
- 13
- 68
- 114
5
votes
1 answer
Linq PredicateBuilder with conditional AND, OR and NOT filters
We have a project using LINQ to SQL, for which I need to rewrite a couple of search pages to allow the client to select whether they wish to perform an and or an or search.
I though about redoing the LINQ queries using PredicateBuilder and have got…

richeym
- 4,049
- 3
- 24
- 23
5
votes
1 answer
T-SQL selecting values that match ISNUMERIC and also are within a specified range. (plus Linq-to-sql)
I am trying to select rows from a table where one of the (NVARCHAR) columns is within a numeric range.
SELECT ID, Value
FROM Data
WHERE ISNUMERIC(Value) = 1 AND CONVERT(FLOAT, Value) < 66.6
Unfortunately as part of the SQL spec the AND clauses…

Toby
- 2,333
- 3
- 16
- 10
5
votes
1 answer
Linq partial match in list?
I have a list of partial strings that I need to match in a table. I'm using PredicateBuilder.
var predicate = PredicateBuilder.False();
List names = new List();
names.Add("test name"); **<===matches**
names.Add("test"); **<===…

John S
- 7,909
- 21
- 77
- 145
4
votes
1 answer
How to create linq predicate with multiple nested "ands" and "ors"
I am trying to dynamically create a linq expression at runtime using PredicateBuilder from http://www.albahari.com/nutshell/predicatebuilder.aspx.
I currently have a method that takes a list of criteria objects, and then parses those into multiple…

Amanda Kitson
- 5,477
- 12
- 49
- 73
4
votes
1 answer
LinqKit PredicateBuilder with EF 4 CPT 5 table relationships?
I'm using LinqKit PredicateBuilder (http://www.albahari.com/nutshell/predicatebuilder.aspx) for a method that do searching. This is how the relationships are built (Entity Framework 4 CPT 5 POCO):
public class MusicSheet
{
[Key]
public int…

Saxman
- 5,009
- 11
- 51
- 72