// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Linq; using System.Data.Objects; namespace TestEF { public class Test { public static void Main(string[] args) { using(TestEFContext ctx = new TestEFContext()) { foreach(make ma in ctx.make.Include("model").OrderBy("it.id")) { Console.WriteLine(ma.id + " " + ma.name); foreach(model mo in ma.model) { Console.WriteLine(" " + mo.id + " " + mo.name); } } var qma = from ma in ctx.make select ma; foreach(var ma in qma) { Console.WriteLine(ma.id + " " + ma.name); var qmo = from mo in ma.model select mo; foreach(var mo in qmo) { Console.WriteLine(" " + mo.id + " " + mo.name); } } } } } }