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
3
votes
2 answers

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 ToCheck(this IQueryable queryable, int age, bool valueToCheck = true) { return…
Benjamin Soulier
  • 2,223
  • 1
  • 18
  • 30
3
votes
0 answers

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 => x.StartDate, x => x.EndDate, asAtDate,…
Drift
  • 31
  • 1
3
votes
1 answer

Get SQL string from Linqkit

how can I return the SQL from a LinqKit.ExpandableQuery? I'm using the code from stevefenton.co.uk but it seems to fail at private static System.Data.Entity.Core.Objects.ObjectQuery GetQueryFromQueryable(IQueryable query) { …
grmbl
  • 2,514
  • 4
  • 29
  • 54
3
votes
2 answers

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(); foreach (var productId in productIds) { …
user1211185
  • 731
  • 3
  • 12
  • 27
3
votes
1 answer

Strange Linq to Entities Behavior with AsExpandable()

Consider the following Person entity: public class Person { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } Using the following Expression (constructed using PredicateBuilder) as…
haim770
  • 48,394
  • 7
  • 105
  • 133
3
votes
1 answer

Linq Expression for matching a complex many-to-many relationship

Let's say I have two entities: public class Animal { public int ID { get; set; } public string Name { get; set; } public bool EatsVegetables { get; set; } public bool EatsMeat { get; get; } public bool EatsFruits { get; set; } } public…
Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
2
votes
0 answers

LinqKit and Filter a subquery

I have a One To many relation (EF) and i want to write a query that filters the One relation AND filters the Many Relation. For instance: Company has Many Employees Write a query that filters on Company.Name = "ZonSoft" and where Company.Employees…
2
votes
0 answers

EF Core 7 Json column projections - LINQKit - LINQ expression could not be translated

I have an issue with mapping an EF Core 7 Json column into an class. I am presented with the following exception. System.InvalidOperationException: The LINQ expression 'JsonQueryExpression(p.Addresses, $.AddressList)' could not be translated.…
2
votes
0 answers

Entity Framework LinqKit dynamic where predicate over related data

The code is in Alpha version, don't have validations or error management ... It would be included later. I have a very simple model with two related entities: Location and Country: public class UNCountry { public int UNCountryId { get; set; } …
Hermann
  • 21
  • 1
2
votes
1 answer

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 Entity Framework. I found the problem is Contains()…
mr.coffee
  • 962
  • 8
  • 22
2
votes
1 answer

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> OttieniElencoArticoliFiltratoComplessoAsync (ExpressionStarter
2
votes
0 answers

LinqKit: AsExpandable not working

Code: public static GetRows() { var to_ret = db.TableRows.Select(x=> new TableRowModel( { TableRowId = x.TableRowId, Type = x.Type, Name = x.Name, …
Shyamal Parikh
  • 2,988
  • 4
  • 37
  • 78
2
votes
1 answer

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. For example: Suppose I have a string filter.…
Jedi31
  • 735
  • 1
  • 6
  • 22
2
votes
0 answers

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 want to run a text search on all the cities : split…
kall2sollies
  • 1,429
  • 2
  • 17
  • 33
2
votes
2 answers

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> assetNamePredicate = m => m.AssetName == "abc"; Expression> assetPurchaseDateFromPredicate = m =>…
Nirman
  • 6,715
  • 19
  • 72
  • 139
1 2
3
9 10