Questions tagged [predicatebuilder]

Allows you to dynamically composing expression predicates to be used in WHERE clauses in LINQ and also in EntityFramework.

241 questions
4
votes
1 answer

PredicateBuilder Where List inside List with C#

I have a problem with PredicateBuilder Class. I have a 3 class like. public class A { public int val1 {get;set;} public int val2 {get;set;} public List listb {get;set;} } public class B { public int val3 {get;set;} public int val4…
Caner
  • 813
  • 1
  • 12
  • 26
4
votes
1 answer

Has anyone been able to use successfully PredicateBuilder from albahari.com against MongoDB?

I have the following code using the popular PredicateBuilder from albahari.com: var predicate = PredicateBuilder.False(); predicate.Or(p => p.Subject.Contains("a")); var test =…
Val
  • 1,023
  • 3
  • 10
  • 21
4
votes
1 answer

PredicateBuilder nests OR clauses, causing nesting-too-deep issues for large predicates

Summary: I'm using PredicateBuilder to Or() several expressions together, then sending that combined expression to OrmLite's Select() method. However, the generated SQL has a WHERE clause with so many nested parentheses that SQL Server throws an…
ean5533
  • 8,884
  • 3
  • 40
  • 64
4
votes
1 answer

Using PredicateBuilder is there a way to build a predicate off of a variable length list of field names?

I have a list containing a variable number of field names. I would like to do a loop through this list and create a predicate that filters for all records that have a value in the field. foreach (var field in FieldNames) { …
John S
  • 7,909
  • 21
  • 77
  • 145
4
votes
0 answers

PredicateBuilder and multilevel nested entitysets

I'm trying to wrap my head around dynamic nested predicate expressions. It's not going too well. Basically I need to be able to create dynamic queries on a fixed set of properties but on a dynamic (and potentially unlimited) number of (nested)…
4
votes
1 answer

PredicateBuilder returning zero records

I'm using PredicateBuilder to create a dynamic Where clause to query data from a DataTable. I have a Dictionary that contains my column names and values I need to search for. I'm simply iterating over the dictionary, if the key matches a column…
Pat Lindley
  • 175
  • 1
  • 9
3
votes
1 answer

PredicateBuilder And or Or

In all the examples I've seen for predicate builder it shows a starting expression with PredicateBuilder.True if you are building an "and" expression criteria and PredicateBuilder.False if you are building an "or" expression criteria. My questions…
Simon Lomax
  • 8,714
  • 8
  • 42
  • 75
3
votes
1 answer

How to remove duplicates from a predicate object?

Let me explain clearly, I have no of search strings and my list contains different fields. Now i will give no of search strings at a time, then my predicate will search each and every item of the list with the search sting. After the match i will…
Sowmya
  • 345
  • 1
  • 5
  • 18
3
votes
2 answers

predicate builder with two tables

A Party can have one or more Contact objects. I want to select all Parties who's streetname contains a specific keyword. If I just want to search in Party I can use the code below. But how do I extend it to also search in Contact? public…
Niklas
  • 13,005
  • 23
  • 79
  • 119
3
votes
1 answer

Trouble with PredicateBuilder

I'm having trouble using PredicateBuilder to dynamically add "Or Where" clauses to a LINQ statement. I'll explain what I'm trying to accomplished first. I have an inverted index that stores keywords from the titles of a bunch of links. I'm using one…
JoshVarty
  • 9,066
  • 4
  • 52
  • 80
3
votes
1 answer

ServiceStack ORMLite JoinAlias on a Where clause

I'm trying to add a Where clause to a table joined with a JoinAlias, but there doesn't appear to be a way to specify the JoinAlias on the where clause. I'm trying to join to the same table multiple times, then add a variable number of where clauses…
KJCM
  • 33
  • 3
3
votes
1 answer

PredicateBuilder: OR condition nested inside .And()

I'm using PredicateBuilder to build a query against a List of Umbraco Nodes to filter search results. I have the searched ID value coming through as a String via the QueryString which I then compare to a string field on each of the Umbraco Nodes in…
user2998091
  • 85
  • 1
  • 4
3
votes
1 answer

C# Pass expression as argument and use PredicateBuilder

I want to dynamically build LinqToSQL and EntityFramework query clauses using a "criteria" object and if necessary leveraging the C# In a Nutshell PredicateBuilder (http://www.albahari.com/nutshell/predicatebuilder.aspx) Just to be clear - I don't…
3
votes
0 answers

Error while re-using an expression using PredicateBuilder in LINQ

I am trying to re-use an expression in a LINQ query but I get an exception saying "Code supposed to be unreachable". I'm not very much versed with PredicateBuilder. So pardon me if I look stupid somewhere. Below are the code snippets. The expression…
user5741254
3
votes
1 answer

How to use predicate builder with linq2sql and OR operator

I have two tables (TABLE1, TABLE2 - unique i know) that has a 1-to-many relationship respectively and a foreign key between ID columns of both tables. Using linq2sql I am trying to select all TABLE1 entries such that their corresponding TABLE2…
David
  • 15,150
  • 15
  • 61
  • 83
1 2
3
16 17