Example #1
0
        // 查询上下文中的所有学生
        public static void Query()
        {
            using (EFTPTEntities context = new EFTPTEntities())
            {
                var people = from p in context.People.OfType<Student>()
                             select p;

                foreach (var s in people)
                {
                    Console.WriteLine("{0} {1} Degree: {2}",
                        s.LastName,
                        s.FirstName,
                        s.Degree);
                }
            }
        }
Example #2
0
        // 查询上下文中的所有学生
        public static void Query()
        {
            using (EFTPTEntities context = new EFTPTEntities())
            {
                var people = from p in context.People.OfType <Student>()
                             select p;

                foreach (var s in people)
                {
                    Console.WriteLine("{0} {1} Degree: {2}",
                                      s.LastName,
                                      s.FirstName,
                                      s.Degree);
                }
            }
        }