Allows you to dynamically composing expression predicates to be used in WHERE clauses in LINQ and also in EntityFramework.
Questions tagged [predicatebuilder]
241 questions
0
votes
1 answer
How can I use PredicateBuilder with repository pattern?
I am trying to use Joseph Albahari's PredicateBuilder with my applications Respository which is giving me the following error:
The best overloaded method match for…

Simon
- 108
- 9
0
votes
1 answer
Ormlite + PredicateBuilder "variable referenced from scope '', but it is not defined"
When I attempt the following:
public List ReturnMatchingMatters(IEnumerable matterNames)
{
var filter = PredicateBuilder.True();
filter = x => matterNames.Any(mattername =>…

SeanKilleen
- 8,809
- 17
- 80
- 133
0
votes
1 answer
Combine And/Or with PredicateBuilder?
I have a list of Ids and I only want to do an AND on the first one and and OR on the subsequent ones. In the past, I have kept a counter variable and when the counter is 1, I do the And, but after that I do an OR, but I was curious if there was an…

Xaisoft
- 45,655
- 87
- 279
- 432
0
votes
1 answer
Dynamic Linq query on List using Predicate Builder
I'm using C# 2010 .NET 4.0 and I have a List collection called returns that I need to build a dynamic LINQ query on.
I'm utilizing the Predicate Builder referenced here.
This works fine if I have 1 filter criteria, but if I have 2 or more, then,…

Shawn Hollon
- 9
- 1
- 5
0
votes
1 answer
can someone further explain this C# code
I am using the PredicateBuilder class from http://www.albahari.com/nutshell/predicatebuilder.aspx
public static Expression> Or (this Expression> expr1,
…

kfc
- 291
- 7
- 24
0
votes
1 answer
Dynamic predicate building in EF5
Ok,
I have to build a predicate to select an unknown number of columns from a known entity in EF5 AND filter by an unknown number of columns ONE of which will always be a name from a child collection.
So this is what I need to end up with
var q =…

PoweredByPorkers
- 243
- 5
- 15
0
votes
1 answer
Querying two different entity types using PredicateBuilder
I am desperately trying to use LinqKits PredicateBuilder to allow the user to enter a search term into a text box and return records from two database tables/entitysets but I'm struggling to get anywhere. The (simplified) database structure is as…

Calanus
- 25,619
- 25
- 85
- 120
0
votes
1 answer
Entity Framework Bug: Exception with PredicateBuilder and comparing nulls
I was able to get my method (below) to run in LinqPad, but when switching to my actual code (using Entity Framework), I get this error:
"Unable to cast the type 'System.Nullable`1' to type 'System.Object'.
LINQ to Entities only supports casting…

Bob Horn
- 33,387
- 34
- 113
- 219
0
votes
1 answer
C# Entity Framework and Predicate Builder - Find the Index of a Matching Row within an IQueryable / Pagination Issue
I have a PredicateBuilder expression which returns an IQueryable like so (contrived example):
var predicate = PredicateBuilder.True();
predicate = predicate.And(x => x.id > 0);
IQueryable results = CoolEntityRepository
…

Aaron Newton
- 2,124
- 1
- 28
- 31
0
votes
2 answers
Optimize Linq query with PredicateBuilder with N-N join
I'm using Linq to query MS CRM 2011 Web Services. I've got a query that results in very poor SQL, it fetches too much intermediary data and its performance is horrible!! I'm new to it, so it may very well be the way I'm using it...
I've got two…

dstj
- 4,800
- 2
- 39
- 61
0
votes
1 answer
PredicateBuilder is still true even after adding explicit false statement
I have the following statement.
var search = PredicateBuilder.True();
search.And(f => false);
// Still the "search" variable value is: {f => true}.
At first, I was trying an expression; nothing succeeded, so I tried this "false" instead.…

Alaa Jabre
- 1,843
- 5
- 26
- 52
0
votes
1 answer
Predicate Builder in MVC 3
I have been messing with Predicate Builder for two days now and although every website says it is super easy to implement for some reason(most likely my fault) I cannot get it to work. I decided to use Predicate builder because I know which columns…

Goldentp
- 187
- 1
- 7
- 28
0
votes
1 answer
MySQL with Predicate Builder not working?
I'm developing a small filtering based on the 3 fields. I'm also using the MySQL Connector in my MVC 3 project.
I've found a nice looking PredicateBuilder http://www.albahari.com/nutshell/predicatebuilder.aspx . but it seems not to be working with…

Tony
- 12,405
- 36
- 126
- 226
-2
votes
1 answer
Multiple dynamic query in Linq
First of all, I will explain the table structure
First table Attribute Second table Category
Id Name Id Name AttributeId(Foreign Key)
------------------ -----------------------------------------
1 Material…

Nighil
- 4,099
- 7
- 30
- 56
-2
votes
3 answers
LINQ not sorting List<> properly
My EF query is supposed to be sorting by the date of the first Product in the list, but for some reason, it only sorts most of the products and some of the dates are in the wrong order.
Here's the code...
using (var context = new SalesEntities())
{
…

Targaryen
- 1,081
- 2
- 17
- 30