예제 #1
0
        static void Main(string[] args)
        {
            var tph = new TPHContext();

            tph.Computers.Add(new Laptop()
            {
                Price = 1000, Description = "Standard Laptop", Weight = 3
            });
            tph.SaveChanges();
            //tph zrobione baza utworzone (podejscie code first)
            var tpt = new TPTContext();

            tpt.Computers.Add(new Laptop()
            {
                Price = 1000, Description = "Lightwaight Laptop", Weight = 1
            });
            tpt.SaveChanges();
            //zrobione  ladniej poukładane powydzielane na ab   stracty na dziedziczone itd ale wada jest ze trzeba robic joiny
            //ale uwaga joiny obnizaja wydajnosc dla tego tph tego nie ma (ale tam dane puchna połowa kolumn nullowych)
            var tpc = new TPCContext();

            tpc.Computers.Add(new Laptop()
            {
                Price = 1000, Description = "Lightwaight Laptop", Weight = 1
            });
            tpc.SaveChanges();
            //tutaj zrobione juz TPC nie bedzie computers tylko pc i laptops mamy dwie tabele z relacja ale brak joinow odczyty szybkie


            Console.WriteLine("Ready");
            Console.ReadKey();
        }
예제 #2
0
        //Add-Migration InitialCreate
        //update-database
        static void Main(string[] args)
        {
            using (var context = new TPTContext())
            {
                Console.WriteLine("All courses:");
                foreach (var course in context.Courses)
                {
                    Console.WriteLine("{0}\t{1}", course.CourseId, course.CourseName);
                }

                Console.WriteLine("Online only: ");
                foreach (var course in context.OnlineCourses)
                {
                    Console.WriteLine("{0}\t{1}\t{2}", course.CourseId, course.Course.CourseName, course.SelfPaced);
                }

                Console.WriteLine("Lab only: ");
                foreach (var course in context.LabCourses)
                {
                    Console.WriteLine("{0}\t{1}\t{2}", course.CourseId, course.Course.CourseName, course.Location);
                }
                OnlineCourse online = new OnlineCourse()
                {
                    Course = new Course()
                    {
                        CourseName = "Added In time " + DateTime.Now,
                        Price      = 123
                    },
                    SelfPaced = true
                };

                LabCourse lab = new LabCourse()
                {
                    Course = new Course()
                    {
                        CourseName = "Added In time " + DateTime.Now,
                        Price      = 123
                    },
                    Location = "Home Center",
                };
                context.OnlineCourses.Add(online);
                context.LabCourses.Add(lab);

                context.SaveChanges();
            }
        }