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.

0
votes
0answers
14 views

Get Generated SQL from .net core LinqKit

Regarding use of LinqKit.Microsoft.EntityFrameworkCore v1.1.16 I read that this should be as simple as query.ToString(); But this does not seem to work in .Net core 2.2. You just get a reflection ...
4
votes
1answer
171 views

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 ...
0
votes
1answer
29 views

PredicateBuilder helper function for create expression

i have an form to search criteria, and i use PredicateBuilder to combine all criteras to an WHere Expression - and the EF generate sql for evaluate in DataBase side. for allow the user choise between ...
2
votes
1answer
109 views

LinqKit Predicate Or with Contains evaluates to equals

I am implementing a search for my application. The search works except for when the user's search cascades by searching related entities. I have debugged the code and tested the SQL generated by ...
1
vote
0answers
120 views

C# How To Pass Linq Lambda Parameters to SwitchExpression And Receive Expression<Func<T,object>> in Lambda .Where(…)

C# How To Pass Linq Lambda Parameters to SwitchExpression And Return Expression To .Where(...) Lambda Linq Queryable i write a linq Lambda query that Who i want use Func That Declare ...
0
votes
0answers
44 views

Using LinqKit's expanded expression in AutoMapper configuration

I want to use LinqKit expanded and invoked expressions to map value in AutoMapper config. I have some business logic, represented as Expression<Func<>>, which I use to neatly reuse code ...
0
votes
1answer
409 views

Using Expression<Func<T, TU>> within another Expression<Func<T, TU>>

I'm trying to get my head around combining expressions, looking around it should be possible to do what I'm trying to do but I'm struggling. I have an Expression<Func<class, dynamic>> ...
0
votes
1answer
137 views

Unit test for Expression tree in c#

How do I write a unit test for a Expression tree in C#. I have this class which needs to be tested. This method returns a Expression tree and also gets one as a parameter. code: public ...
1
vote
1answer
85 views

Exception trying to use a basic Expression created with LinqKit

I'm trying to force ef-core to paramerize values that it considers constants as described in this article by using LinqKit. When trying to apply the PredicateBuilder example described on github, I ...
0
votes
0answers
157 views

Using LinqKit to make reusable Linq-to-Entities Expressions

Let's say I have a table Foo with a one-to-many relation to table Bar. Both these tables have a lot of columns, so when I use EntityFramework to get them, I just want to select the columns I need to ...
0
votes
1answer
86 views

How to extend LinqKit and use a custom method within a linq query?

I would like to leverage LinqKit's AsExpandable feature to be able to translate my custom methods inside of my linq query. I can achieve this by implementing my own expression visitor which will ...
2
votes
1answer
331 views

Use PredicateBuilder in SelectMany LINQ to Entity Framework

It's the first time I write here on stackoverflow. I would like to use PredicateBuilder in a LINQ query with SelectMany. I enter my code public async Task<List<Articolo>> ...
2
votes
1answer
466 views

Includes doesn't work with LinqKit AsExpandable

I'm trying to use LinqKit AsExpandable in my EfCore2.0 project and I am running into this problem where the Includes doesn't work. In attempting to debug this I have downloaded the LinqKit source ...
0
votes
1answer
310 views

creating a generic expression to query EntityFramework

I have many entities which were generated by EF against the existing database. Most of these entities have a "name" property. I would like a method which takes in an expression against a generic type, ...
1
vote
1answer
791 views

Entity Framework - LINQ - Use Expressions in Select

I am using within my code some EF LINQ expressions to keep complex queries over my model in one place: public static IQueryable<User> ToCheck(this IQueryable<User> queryable, int age, ...
0
votes
2answers
517 views

How to combine multiple Expression<Func<T, bool>> into a single expression to execute against DbContext?

I'm trying to create a way to allow users of my app to create their own filter views of data. To do that I'm composing a list of Key-Operator-Value pairs which I then try, after multiple steps, to ...
0
votes
1answer
1k views

How to unit test an expression? [duplicate]

I have looked at a few posts such as this one but it doesn't answer my question. Basically I have use LINQKIT to build an expression which looks like this: public Expression<Func<uv_Manifest, ...
1
vote
1answer
394 views

Lambda expression to create AND filter

I used this code to create a search filter. I need is to pass an array of data and filter this data by AND. Expression<Func<serveis, bool>> CombineWithAnd<T>(Expression<Func<...
2
votes
0answers
399 views

LinqKit: AsExpandable not working

Code: public static GetRows() { var to_ret = db.TableRows.Select(x=> new TableRowModel( { TableRowId = x.TableRowId, Type = x.Type, ...
7
votes
1answer
3k views

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<CastInfo>(true); ...
1
vote
0answers
140 views

The parameter was not bound in the specified LINQ to Entities query expression

I'm currently struggeling with building dynamic queries using LINQKit. For my particular entity User I have the following property defined: public static Expression<Func<User, MyEntites, int&...
4
votes
1answer
577 views

Adding to Lambda Expression and work with Entity Framework

If I want retrieve more columns with an already existing lambda tree expression like below, how would I do that? This works with Entity Frameworks and want it to still work. Expression<Func<...
0
votes
1answer
787 views

Predicate Building with subquery using LinqKit

I am trying to work out how to build a predicate with a subquery that references the parent query. Example: I have 2 classes (Foo and Bar, of course). The ReferenceId of Bar refers to (in this ...
0
votes
1answer
1k views

Generic Query With PredicateBuilder in Linqkit

I've been using LinqKit to create generic queries for quite some time. One thing that has always bothered me is the fact that you always have to test whether the value sent in the filter is valid. ...
1
vote
1answer
382 views

Static expression as instance-property for dynamic linq-queries

I'm using a modified version of LinqKit in order to have my extensions at one place. Therefore I have a singel part of each of my entity-classes where I define my expression, e.g. for tblMain: ...
0
votes
2answers
279 views

Building expressions in c# with LinqKit

Is there a way to to ignore initial true expression, if parameters for query are supplied var query = ctx.Articles .AsNoTracking() .WithSmallIncludes(); ...
3
votes
1answer
210 views

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. ...
1
vote
1answer
366 views

A cycle was detected in a LINQ expression Linqkit

I have one expression , for example x=>x.Id ; And I have a function, where I need to combine two expressions. I use Linqkit . My model: public class Model{ Expression<Func<Entity,bool&...
1
vote
0answers
369 views

Is it possible to insert a LinqKit PredicateBuilder as a sub query?

I've currently got a working multi level predicate shown below... var predicate = PredicateBuilder.New<Patient>(); foreach (var code in codeArray) // ect..["AB12", "W231", "Q213"] { string ...
1
vote
2answers
169 views

howt to Include related entities with filter condition using AsExpandable

I want to include related entities with some filter condition. Is this possible ?? I don't want to write projection query for this. So I was trying to achieve this by below code...... but it's not ...
0
votes
2answers
50 views

How to compound Expressions of similar types?

I have two expressions, of the same type: Expression<Func<IQueryable<T>, IQueryable<T>>> exprA, exprB; I would like to combine these two expressions, so that semantically it ...
2
votes
0answers
177 views

Exception when using linqkit: Unable to cast object of type TypedParameterExpression to type LambdaExpression

first time I've not managed to find an existing answer to my problem. Basically I have a generic expression to allow filtering active items on an IQueryable usage: queryableGoesHere.ActiveAtItems(x =...
0
votes
1answer
104 views

Concat linq to objects Or queries with LINQKIT during runtime

I have a list of multiple values 3,5,10. Now I want to create a linq .where filter during runtime with the Or operator. How can I do this using LINQKit? Or with plain linq but I dont think its ...
2
votes
0answers
626 views

Cast exception with LinqKit's PredicateBuilder on Entity Framework 7

I have a simple EF7 code-first model : Countries have States, States have Cities. Relations and inverse relations are defined so that navigation fields and collections can be traversed both ways. I ...
4
votes
1answer
809 views

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 ...
2
votes
1answer
410 views

Get SQL string from Linqkit

how can I return the SQL from a LinqKit.ExpandableQuery<T>? I'm using the code from stevefenton.co.uk but it seems to fail at private static System.Data.Entity.Core.Objects.ObjectQuery<T> ...
0
votes
1answer
271 views

How to use linqkit like

data Name{"divan","dîvan","divân","dîvân" } I want to something like select * from data where Name like % d_v_n % in linq then the expected result would be "divan","dîvan","divân","dîvân" //this ...
0
votes
1answer
117 views

Simple Linq expression producing bloated where clause that doesn't make sense to me

I am trying to use this Linq expression Dim ex2 As Expression(Of Func(Of Advertisement, Boolean)) = Function(a) a.Address.CountryCode = ISO AndAlso a.Address.Region = EmptyString in this manner ...
-2
votes
3answers
107 views

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 ...
1
vote
1answer
94 views

LinqPad Predicatebuider Expression call not working

I am trying to get the examples working found at http://www.albahari.com/nutshell/predicatebuilder.aspx I have the following code: public partial class PriceList { public string ...
3
votes
1answer
552 views

“Include” extension method does not work with LinqKit

I have 2 classes: public class Employee { public int Id {get;set;} public string Name {get;set;} } public class Remuneration { public int Id {get;set;} public Employee Employee {get;...
1
vote
2answers
532 views

How to include child entities (navigation) while using .AsExpandable() of LinqKIT

I am using .AsExpandable() extension of LinqKIT to dynamically generate Where expression. For example, Expression<Func<Asset, bool>> assetNamePredicate = m => m.AssetName == "abc"; ...
0
votes
0answers
553 views

Function Call inside IQueryable's Select Anonymous object

I have the following code: Expression<Func<int, string>> myStatusCode = (t) => PluginApplication.Types.ToTypeName(t); var model =_context.UsersRepository.Include("Emails")....
0
votes
2answers
278 views

How to parametrize a query in Entity Framework?

I am new to EF. I have a table with a list of projects. I have found a query in my software that finds all projects . public Project[] FindAll() { var projects = new List<Project>(); ...
5
votes
3answers
636 views

How to check if predicate expression was changed?

var predicate = PredicateBuilder.True<o_order>(); This is my predicate expression, where on some certain conditions I will append expressions with it. Likewise if (!string.IsNullOrEmpty(...
2
votes
1answer
544 views

Linq predicate query results is not working for further Linq Join

I am using results from Predicate query to write join in Linq query. But it is throwing the following error. However when I run similar query in SQL, it returns the expected results. var predicate = ...
3
votes
2answers
204 views

How to use predicates with LINQ to query CRM 2011

I am trying to use linqkit to Predicate. Getting following code when I am trying to compile. public void TestPredicate(Guid[] productIds) { var predicate = PredicateBuilder.False<Product>();...
1
vote
0answers
778 views

how to use predicate into a join statement

I am trying to allow my users to construct their own queries. I found this code which seems to solve this problem: var predicate = PredicateBuilder.True<T1>(); if (a != "") predicado = ...
1
vote
1answer
343 views

LinqKit Predicates

I am trying to figure out how the Predicates work. I have a piece of code where one parameter will always be supplied but there could be up to 5 different parameters. If I try this way var ...
0
votes
1answer
973 views

LinqKit PredicateBuilder adding to linq query

I have a linq query which I want to add some additional, optional WHERE conditions to using LinqKit Predicate Builder. However, I an struggling to get the additional predicate to work This is my ...