using System.Collections.Generic;
using System.Data.Entity;
using System.Linq.Expressions;
using System.Linq.Dynamic.Core;
public static void Main()
using (var context = new EntityContext())
Expression<Func<Customer, bool>> e1 = c => c.City == "Paris";
var e2 = DynamicExpressionParser.ParseLambda<Customer, bool>(new ParsingConfig(), true, "c => c.CompanyName != \"test\"");
var customers = context.Customers.ToList().AsQueryable().Where("@0(it) and @1(it)", e1, e2);
FiddleHelper.WriteTable(customers);
public static void GenerateData()
List<Customer> list = new List<Customer>();
Name = "Terri Lee Duffy",
Orders = new List<Order>()
new Order() { Date = DateTime.Today.AddDays(-41) },
new Order() { Date = DateTime.Today.AddDays(-38) },
new Order() { Date = DateTime.Today.AddDays(-21) },
new Order() { Date = DateTime.Today.AddDays(-18) },
new Order() { Date = DateTime.Today.AddDays(-10) },
new Order() { Date = DateTime.Today.AddDays(-9) },
new Order() { Date = DateTime.Today.AddDays(-5) },
new Order() { Date = DateTime.Today },
Orders = new List<Order>()
new Order() { Date = DateTime.Today.AddDays(-25) },
new Order() { Date = DateTime.Today.AddDays(-11) },
new Order() { Date = DateTime.Today.AddDays(-7) },
new Order() { Date = DateTime.Today }
Orders = new List<Order>()
new Order() { Date = DateTime.Today.AddDays(-4) },
new Order() { Date = DateTime.Today }
Name = "Michael Sullivan",
Orders = new List<Order>()
new Order() { Date = DateTime.Today.AddDays(-35) },
new Order() { Date = DateTime.Today.AddDays(-21) },
new Order() { Date = DateTime.Today.AddDays(-17) },
new Order() { Date = DateTime.Today.AddDays(-11) },
new Order() { Date = DateTime.Today.AddDays(-4) },
new Order() { Date = DateTime.Today }
Name = "Rebecca Bradley",
Orders = new List<Order>()
new Order() { Date = DateTime.Today.AddDays(-21) },
new Order() { Date = DateTime.Today.AddDays(-18) },
new Order() { Date = DateTime.Today.AddDays(-10) },
new Order() { Date = DateTime.Today.AddDays(-9) },
using (var context = new EntityContext())
context.Customers.AddRange(list);
context.BulkSaveChanges();
using (var context = new EntityContext())
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Customer> Customers { get; set; }
public DbSet<Order> Orders { get; set; }
public int CustomerID { get; set; }
public string Name { get; set; }
public string CompanyName { get; set; }
public string City { get; set; }
public string Phone { get; set; }
public List<Order> Orders { get; set; }
public int OrderID { get; set; }
public DateTime Date { get; set; }