Entity Framework Classic LINQ Dynamic

Description

You can execute query dynamically through free extensions provided by the library Eval-Expression.NET.

This feature is available for free in the EF Classic Community.

Predicate

All LINQ predicate methods are supported.

var list = context.Customers.WhereDynamic(x => "x.IsActive").ToList();
var list2 = context.Customers.WhereDynamic(x => "x.IsActive == IsActive", new { IsActive = false }).ToList();

Try it: NET Core | NET Framework

Deferred Methods
Name Description Example
OrderByDescendingDynamic Sorts the elements of a sequence in descending order using a dynamic expression. NET Core / NET Framework
OrderByDynamic Sorts the elements of a sequence in ascending order using a dynamic expression. NET Core / NET Framework
SelectManyDynamic Projects each element of a sequence to an IEnumerable and flattens the resulting sequences into one sequence using a dynamic expression. NET Core / NET Framework
SelectDynamic Projects each element of a sequence into a new form using a dynamic expression. NET Core / NET Framework
SkipWhileDynamic Skip all elements until the predicate is not satisfy.
TakeWhileDynamic Take all elements until the predicate is not satisfy.
ThenByDescendingDynamic Performs a subsequent ordering of the elements in a sequence in descending order using a dynamic expression. NET Core / NET Framework
ThenByDynamic Performs a subsequent ordering of the elements in a sequence in ascending order using a dynamic expression. NET Core / NET Framework
WhereDynamic Filters a sequence of values based on a predicate using a dynamic expression. NET Core / NET Framework
Immediate Methods
Name Description Example
AllDynamic Determines whether all elements of a sequence satisfy a condition using a dynamic expression. NET Core / NET Framework
AnyDynamic Determines whether any element of a sequence exists or satisfies a condition using a dynamic expression. NET Core / NET Framework
CountDynamic Returns the number of elements in a sequence using a dynamic expression. NET Core / NET Framework
FirstDynamic Returns the first element of a sequence using a dynamic expression. NET Core / NET Framework
FirstOrDefaultDynamic Returns the first element of a sequence, or a default value if no element is found using a dynamic expression. NET Core / NET Framework
LongCountDynamic Returns an Int64 that represents the number of elements in a sequence using a dynamic expression. NET Core / NET Framework
SingleDynamic Returns a single, specific element of a sequence using a dynamic expression. NET Core / NET Framework
SingleOrDefaultDynamic Returns a single, specific element of a sequence, or a default value if that element is not found using a dynamic expression. NET Core / NET Framework

Execute

The Execute method is the LINQ Dynamic ultimate methods which let you evaluate and execute a dynamic expression and return the result.

var list = context.Customers.Execute<IEnumerable<Customer>>("Where(x => x.IsActive == true)").ToList();
var list2 = context.Customers.Execute<IEnumerable<Customer>>("Where(x => x.IsActive == IsActive)", new { IsActive = false }).ToList();

Try it: NET Core / NET Framework

Methods
Name Description Example
Execute Execute LINQ dynamic using an expression. NET Core / NET Framework
Execute<TResult> Execute LINQ dynamic using an expression. NET Core / NET Framework


Contents

Related