zzz projects Entity Framework Core EF Core
Home Articles Knowledge Base Online Examples
  • Home
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework Core - Knowledge Base (KB)

26 results in tag: lambda

Use method in entity framework query

Is there anyway around this error? I'd like to reuse the same lamba expression in other queries instead of having duplication. Can LinqKit or other linq expression do this?...Error...LINQ to Entities does not recognize the method 'Boolean GetEvent(Tournam...
entity-framework entity-framework-6 lambda linq
asked by Mike Flynn

EF Core helper method for explicit loading references and collections

EF Core has support for ...explicit loading.... The context has two overloads, one for references and one for collections....Having two methods is not useful, and gets messy. I want a single method for accepting both as a params array....So instead of thi...
c# entity-framework entity-framework-core lambda reflection
asked by grokky

Entity Framework combine lambda expressions from different entities

I have 2 lambda expressions that are virtually the same. One returns ...Expression<Func<Person, bool>>... and the other returns ...Expression<Func<Admission, bool>>.......There is a direct relationship between these 2 entities. A ...Person... can have man...
c# entity-framework entity-framework-6 expression lambda
asked by Gwasshoppa

How to write Repository method for .ThenInclude in EF Core 2

I'm trying to write a repository method for Entity Framework Core 2.0 that can handle returning child collections of properties using .ThenInclude, but I'm having trouble with the second expression. Here is a working method for .Include, which will return...
.net-core c# entity-framework-core lambda repository-pattern
asked by redwards510

How to pass lambda 'include' with multiple levels in Entity Framework Core?

I have a repository that gets a lambda expression for 'include'. ...public TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate, params Expression<Func<TEntity, object>>[] includePaths) { return Context.Set<TEntity>().Includes(incl...
asp.net c# entity-framework-core include lambda
asked by Igor

Custom Sorting using c# Linq Expressions

I'm trying to make sorting easier for an C# Application and C# Web API. I'm using Entity Framework Core for my persistence and testing....In my application or Web API I determine the Order, Descending or Ascending, Property Name....I pass this knowledge ...
c# entity-framework-core lambda linq sorting
asked by chris31389

Store Lambda expressions as variable

Is it possible to store a lambda expression as a variable and use it in multiple places. My db objects have an ...Id... as int and a ...UId... as an uniqueidentifier and I have to write very similar expressions when selecting based on ...Id... or ...UId..
c# entity-framework entity-framework-core lambda
asked by Stein The Ruler

Reusing Lambda Select Fragments in LINQ

I would like to be able to reuse ...fragments... of my select lambda expressions in my Entity Framework Core 2.0 queries. ...For example:...var result = await ctx.Customers .Select(cust => new CustomerDto { CustomerId = cust.Id, CustomerName = ...
c# entity-framework-core lambda linq
asked by Neilski

How To create linq Expression dynamically in c# for Contains

I am trying to create expression dynmically but i could not figure it out... Also dont want to use like this.....if (item.id == 1) filter.AddExpression(c => filterValues.Contains(c.a1)); if (item.id == 2) filter.AddExpression(c => filterValues.Contains(c....
entity-framework-core lambda linq reflection
asked by kanpinar

How can I implement a LEFT OUTER JOIN in LINQ using lambda syntax on Entity Framework Core 2.0?

I am trying to implement a LEFT OUTER JOIN in Linq against an Entity Framework Core 2.0 DbContext. It's important that the query is translated to SQL, rather than evaluated locally. I've reviewed several StackOverflow solutions including ...this one... ...
.net-core c# entity-framework-core lambda linq
asked by Peter

Nested Expression method call in Linq.Select()

I use ....Select(i=> new T{...})... after every db hit manually to convert my entity objects into DTO object. Here are some sample entities and DTOS...User Entity;...public partial class User { public int Id { get; set; } public string Username { ...
c# entity-framework-core expression lambda linq
asked by ilkerkaran

How to create a Stuff and XML PATH(SQL) in Linq or Lambda

How to create the equivalent code in Linq or lambda?...I'm using Entity Framework Core on Asp.net Core 2....SELECT (SELECT STUFF((SELECT DISTINCT ', ' + Roles.Name FROM AspNetUsers Users INNER JOIN AspNetUser...
c# entity-framework-core lambda linq sql-server
asked by Leonardo Pavanello

Include the IsDeleted values when user is admin

I want to include the ...isDeleted... values in the database to my index when the user is an admin. I used the global query filter to filter the data. ...This is the code I have:...var param = Expression.Parameter(entity.ClrType); var propertyMethodInfo ...
c# entity-framework-core lambda
asked by darwin

Combine BinaryExpression and Expression<Func<dynamic, bool>> in C#

How can I combine ...BinaryExpression... and ...Expression<Func<dynamic / T, bool>>...?...For example:...void AddGlobalFilter<T>(Expression<Func<T, bool>> expr) { var parameter = Expression.Parameter(type, "t"); var member = Expression.Property(fi...
c# entity-framework-core entity-framework-core-2.1 expression-trees lambda
asked by Makla

Dynamic query filter expression in include

i am working with the entity framework core HasQueryFilter method while having a dynamic variable within this filter expression. Because of this dynamic parameter (lets name it "MinPriority") i cannot directly pass a lambda expression like...HasQueryFilte...
asp.net-core c# entity-framework entity-framework-core lambda
asked by cyptus

How to create "inline if statement" with expressions in dynamic select for null checking

How to create "inline if statement" with expressions in dynamic select for null checking ...I was wrote a dynamic linq select expression for a nested property of a object, but it throw an exception when it is null. so i want to check whether that property...
c# entity-framework-core expression lambda linq
asked by Mohammad

Group Join Select With Comma Separated

I have a query Like below in .net Core 2.2 with EF....var data = context.Customer .GroupJoin(context.Orders, c=> c.Id, o => o.CustoerId, (c, o) => new { customer = c, ...
c# entity-framework-core lambda linq
asked by AKASH

Modifying an Entity Framework expression when tables have been remapped

I have an issue now that a table has had an id removed....First I had this query below where entity (table) 'RecordsProduct' has a 'DefendnatId' that was mapped to a Defendant table. It was fine! ... records = records .Include(r...
c# entity-framework-core lambda
asked by user1186050

Re-implementation of OrderBy, ThenBy and Null TypeMapping in Sql Tree error

I am trying to implement ...OrderBy... and ...ThenBy... in a different way to hide lambda expression from ...OrderBy... and ...ThenBy... extension methods. These extension methods accept classes which implement ...IOrderSpecification...: ...public class P...
c# entity-framework-core expression-trees lambda linq
asked by peyman gilmour

C# Entity Framework Core Conditional Projection

I currently use Entity Framework Core, and it works really well. However, one things I am trying to optimise in my application is returning computed data from the database at the time of querying. I am using code first, where each model directly maps to a...
c# entity-framework-core lambda projection
asked by Eliott Robson

Page 1 of 2
  • 1
  • 2
  • ยป

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!