private static void UseObjectQuery() { using (var data = new Formula1Entities()) { ObjectQuery <Racer> racers = data.CreateQuery <Racer>("[Formula1Entities].[Racers]"); Console.WriteLine(racers.CommandText); Console.WriteLine(racers.ToTraceString()); } }
private static void EntitySQL() { using (var data = new Formula1Entities()) { string country = "Brazil"; ObjectQuery <Racer> racers = data.CreateQuery <Racer>( "SELECT VALUE it FROM ([Formula1Entities].[Racers]) AS it WHERE it.Country = @Country", new ObjectParameter("Country", country)); foreach (var r in racers) { Console.WriteLine("{0} {1}", r.Firstname, r.Lastname); } } }