Dynamic Query

Introduction

Dynamic Query allows you to perform dynamic where clause, select, order by, with string expression at runtime.

Why Dynamic Query?

Common Scenarios:

  • Use dynamic select clause with string expression
  • Use dynamic order by with string expression
  • Use dynamic where clause with string expression

Example

var customersList1 = context.Customers
.OrderByDynamic(c => "c.Name")
.ToList();

var customersList2 = context.Customers
.Include(x => x.Invoices)
.Where(c => "c.Invoices.Count > 0")
.OrderByDescendingDynamic(c => "c.Invoices.Count")
.ToList();

Supported Libraries

Library Type EF Version Support Doc Features
Eval Expression.NET FREE/PRO All < 1 Day Yes Dynamic Query
System.Linq.Dynamic FREE All < 1 Day Yes Dynamic Query