using System.Collections.Generic;
using System.Data.Entity;
using System.Linq.Dynamic.Core;
public static void Main()
Person magnus = new Person { Name = "Hedlund, Magnus" };
Person terry = new Person { Name = "Adams, Terry" };
Person charlotte = new Person { Name = "Weiss, Charlotte" };
Pet barley = new Pet { Name = "Barley", Owner = terry };
Pet boots = new Pet { Name = "Boots", Owner = terry };
Pet whiskers = new Pet { Name = "Whiskers", Owner = charlotte };
Pet daisy = new Pet { Name = "Daisy", Owner = magnus };
var persons = new List<Person> { magnus, terry, charlotte };
var pets = new List<Pet> { barley, boots, whiskers, daisy };
(person, pet) => new { OwnerName = person.Name, Pet = pet.Name });
FiddleHelper.WriteTable(realQuery);
var dynamicQuery = persons.AsQueryable()
"new(outer.Name as OwnerName, inner.Name as Pet)");
foreach (dynamic result in dynamicQuery)
FiddleHelper.Dump(result);
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Pet> Pets { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public Person Owner { get; set; }