Exemple #1
0
        private static void SimpleNinjaQueryEntitySQL_Reader()
        {
            using (EntityConnection conn = new EntityConnection("name=NinjaObjectContext"))
            {
                //context.Database.Log = Console.WriteLine;
                conn.Open();
                var cmd = conn.CreateCommand();
                cmd.CommandText = @"SELECT VALUE n 
                                    FROM NinjaObjectContext.Ninjas AS n
                                    WHERE n.DateOfBirth > @dob";
                cmd.Parameters.AddWithValue("dob", new DateTime(1984, 1, 1));


                using (EntityDataReader dr = cmd.ExecuteReader(
                           System.Data.CommandBehavior.SequentialAccess))
                {
                    while (dr.Read())
                    {
                        Console.Out.WriteLine(dr.GetString(1) + " " + dr.GetDateTime(4));
                    }
                }
            }
        }