Questions tagged [linqkit]

LINQKit is a free set of LINQ extensions, aimed primarily at LINQ to SQL. With LINQKit, developers can: Plug expressions into EntitySets, use expression variables in subqueries, combine expressions (have one expression call another), dynamically build query predicates, and leverage AsExpandable to add new extensions.

142 questions
37
votes
2 answers

Howto use predicates in LINQ to Entities for Entity Framework objects

I'm using LINQ to Entities for Entity Framework objects in my Data Access Layer. My goal is to filter as much as I can from the database, without applying filtering logic to in-memory results. For that purpose Business Logic Layer passes a…
bairog
  • 3,143
  • 6
  • 36
  • 54
26
votes
2 answers

Is there a particular reason LinqKit's expander can't pick up Expressions from fields?

I'm using LinqKit library which allows combining expressions on the fly. This is a pure bliss for writing Entity Framewok data acess layer because several expressions can optionally be reused and combined, which allows both for readable and…
Dan Abramov
  • 264,556
  • 84
  • 409
  • 511
20
votes
2 answers

LinqKit System.InvalidCastException When Invoking method-provided expression on member property

Given a simple parent/child class structure. I want to use linqkit to apply a child lambda expression on the parent. I also want the Lambda expression to be provided by a utility method. public class Foo { public Bar Bar { get; set;…
user293499
  • 203
  • 2
  • 4
15
votes
2 answers

LINQKit: nesting an ExpandableQuery in LINQ to Entities

I've been attempting to incorporate LINQKit into a shared data access layer, however, I have hit a roadblock. When constructing a nested query using an ExpandableQuery, the expression parser is unable to correctly unwrap the ExpandableQuery and…
Nyk
  • 151
  • 4
15
votes
2 answers

Difference between PredicateBuilder and PredicateBuilder?

I have the code: var predicate = PredicateBuilder.True(); predicate = predicate.And(x => x.value1 == "1"); predicate = predicate.And(x => x.value2 == "2"); var vals = Value.AsExpandable().Where(predicate).ToList(); If I have…
Xaisoft
  • 45,655
  • 87
  • 279
  • 432
13
votes
2 answers

Use LinqKit PredicateBuilder for related model (EF Core)

I want to use LinqKit's PredicateBuilder and pass the predicate into .Any method for related model. So I want to build a predicate: var castCondition = PredicateBuilder.New(true); if (movies != null && movies.Length > 0) { …
Igor
  • 3,129
  • 1
  • 21
  • 32
12
votes
1 answer

LinqKit and async in Entity Framework

I am getting the following error when using the predicate builder with Entity Framework Core. The source IQueryable doesn't implement IAsyncEnumerable. Only sources that implement IAsyncEnumerable can be used for Entity Framework asynchronous…
Bryan
  • 5,065
  • 10
  • 51
  • 68
8
votes
1 answer

Nesting PredicateBuilder predicates : 'The parameter 'f' was not bound in the specified LINQ to Entities query expression'

I am building predicates using LinqKit's PrediateBuilder class to dynamically setup filters and I want to combine a nested one to another. I have read this (http://www.albahari.com/nutshell/predicatebuilder.aspx) : Here is my code : // The main…
user2324540
6
votes
1 answer

EFCore enum to string value conversion not used in where clause

I am having a problem with how my Linq where clause gets translated into Sql. I am using EnumToStringConverter to map a property of my entity that is an enum into a text db column. This all works fine when just querying my entity from the…
Francesco D.M.
  • 2,129
  • 20
  • 27
6
votes
4 answers

Call Ignore Case for Contains Method using a generic LINQ Expression

I am using below code for Generic Filter, any search text passed but the contains method is Case sensitive, how can I write to ignore case. public static class QueryExtensions { public static IQueryable Filter(this IQueryable query,…
ineffable p
  • 1,207
  • 2
  • 22
  • 46
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

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."…
5
votes
1 answer

How to use an Expression> in a Linq to EF where condition?

There have already been some questions about this topic (for instance Expression.Invoke in Entity Framework?), however, I could not find an answer for my specific situation. I would like to define a method like this: public IQueryable
Mark Vincze
  • 7,737
  • 8
  • 42
  • 81
5
votes
1 answer

StackOverflowException using Linq(Kit) for nested data

I'm trying to build a nested query using Linq/LinqKit. In theory this seems to be easy. But I am stuck with the practical part. In my database I have a table which has a self-reference to its parent. In my linq-query I now want to select all parents…
KingKerosin
  • 3,639
  • 4
  • 38
  • 77
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
1
2 3
9 10