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.Where(x => "x.IsActive").ToList();
var list2 = context.Customers.Where(x => "x.IsActive == IsActive", new { IsActive = false }).ToList();

Try it: NET Framework | NET Core

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

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 Framework | NET Core

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

Contents