Exemplo n.º 1
0
        static void Main(string[] args)
        {
            using (var db = new StudentsContext())
            {
                //    Students Student = new Students { Fname = "Kobe", Lname = "Bryant", ID = 8, Address = "1111 S Figueroa St", City = "Los Angeles" };
                //    db.Students.Add(Student);
                //    Students Student2 = new Students { Fname = "Zeke", Lname = "Elliot", ID = 21, Address = "1 AT&T Way", City = "Arlington" };
                //    db.Students.Add(Student2);
                //    Students Student3 = new Students { Fname = "Lavar", Lname = "Ball", ID = 1, Address = "3 B Baller Way", City = "Big Baller Village" };
                //    //db.Students.Add(Student3);
                //    db.SaveChanges();
                //};
                //db.Books.Add(book1);

                //using (var db = new CoursesContext())
                //{
                //    Courses Course = new Courses { Title = "Geometry", Dept = "Math", CRN =102 };
                //    Courses Course2 = new Courses { Title = "Chemisty", Dept = "Science", CRN = 1212 };
                //    Courses Course3 = new Courses { Title = "Gym", Dept = "Physical Education", CRN = 501 };
                //}

                //using (var db = new CoursesContext())
                //{
                //    Scores Score = new Scores { Homework = "98% A+", Description = "Estimate your neighbors internet bill", Points = 98 };
                //    Scores Score2 = new Scores { Homework = "76% C", Description = "Fuse 2 Atoms together", Points = 76 };
                //    Scores Score3 = new Scores { Homework = "58% F+", Description = "", Points = 58 };
                //}

                Student Student1 = new Student
                {
                    Fname = "Kobe",
                    Lname = "Bryant",

                    Address    = "1111 S Figueroa St",
                    City       = "Los Angeles",
                    State      = "Ca",
                    Courses_ID = new List <Course>()
                };
                db.Students.Add(Student1);

                Student Student2 = new Student
                {
                    Fname      = "Zeke",
                    Lname      = "Elliot",
                    Address    = "1 AT&T Way",
                    City       = "Arlington",
                    State      = "TX",
                    Courses_ID = new List <Course>()
                };
                db.Students.Add(Student2);

                Student Student3 = new Student
                {
                    Fname      = "Lavar",
                    Lname      = "Ball",
                    Address    = "3 B Baller Way",
                    City       = "Big Ballerville",
                    State      = "CA",
                    Courses_ID = new List <Course>()
                };
                db.Students.Add(Student3);


                Course Class1 = new Course
                {
                    Title      = "Geometry",
                    CRN        = 102,
                    Dept       = "Math",
                    Points     = "98",
                    Instructor = "Skip Bayless",
                    Scores_ID  = new List <Score>()
                };
                Student2.Courses_ID.Add(Class1);

                Course Class2 = new Course
                {
                    Title      = "Chemistry",
                    CRN        = 1212,
                    Dept       = "Science",
                    Points     = "76",
                    Instructor = "Stephen A Smith",
                    Scores_ID  = new List <Score>()
                };
                Student1.Courses_ID.Add(Class2);

                Course Class3 = new Course
                {
                    Title      = "Gym",
                    CRN        = 501,
                    Dept       = "Physical Education",
                    Points     = "58",
                    Instructor = "Shannon Sharpe",
                    Scores_ID  = new List <Score>()
                };
                Student2.Courses_ID.Add(Class3);

                Score Score = new Score
                {
                    Type        = "HW",
                    Description = "Estimate your neighbor's WiFi password",
                    Points      = 98,
                };
                Class2.Scores_ID.Add(Score);

                Score Score2 = new Score
                {
                    Type        = "Quiz",
                    Description = "Fuse 2 Atoms together",
                    Points      = 76,
                };
                Class3.Scores_ID.Add(Score2);

                Score Score3 = new Score
                {
                    Type        = "Exam",
                    Description = "Run a sub 5.0 Second 40 yard dash",
                    Points      = 58,
                };
                Class2.Scores_ID.Add(Score3);
                db.SaveChanges();
                var query = from student in db.Students
                            orderby student.Address
                            select student;

                WriteLine("Students first name is");
                WriteLine();
                foreach (var student in query)
                {
                    Console.WriteLine($"{student.Fname}  {student.Lname}");

                    foreach (var Student in query)
                    {
                        WriteLine($"- Title: {Score.Type}");
                        WriteLine($"-- Student in Class: {Student2.ID}");
                    }
                    WriteLine();
                }

                WriteLine("Press a key to exit...");
                ReadKey();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            using (var db = new StudentsContext())
            {
                //    Students Student = new Students { Fname = "Kobe", Lname = "Bryant", ID = 8, Address = "1111 S Figueroa St", City = "Los Angeles" };
                //    db.Students.Add(Student);
                //    Students Student2 = new Students { Fname = "Zeke", Lname = "Elliot", ID = 21, Address = "1 AT&T Way", City = "Arlington" };
                //    db.Students.Add(Student2);
                //    Students Student3 = new Students { Fname = "Lavar", Lname = "Ball", ID = 1, Address = "3 B Baller Way", City = "Big Baller Village" };
                //    //db.Students.Add(Student3);
                //    db.SaveChanges();
                //};
                //db.Books.Add(book1);

                //using (var db = new CoursesContext())
                //{
                //    Courses Course = new Courses { Title = "Geometry", Dept = "Math", CRN =102 };
                //    Courses Course2 = new Courses { Title = "Chemisty", Dept = "Science", CRN = 1212 };
                //    Courses Course3 = new Courses { Title = "Gym", Dept = "Physical Education", CRN = 501 };
                //}

                //using (var db = new CoursesContext())
                //{
                //    Scores Score = new Scores { Homework = "98% A+", Description = "Estimate your neighbors internet bill", Points = 98 };
                //    Scores Score2 = new Scores { Homework = "76% C", Description = "Fuse 2 Atoms together", Points = 76 };
                //    Scores Score3 = new Scores { Homework = "58% F+", Description = "", Points = 58 };
                //}

                Students Student1 = new Students
                {
                    Fname = "Kobe",
                    Lname = "Bryant",

                    Address = "1111 S Figueroa St",
                    City    = "Los Angeles",
                    State   = "Ca",
                };
                db.Students.add(Student1);

                Students Student2 = new Students
                {
                    Fname   = "Zeke",
                    Lname   = "Elliot",
                    Address = "1 AT&T Way",
                    City    = "Arlington",
                    State   = "TX",
                };
                db.Students.add(Student2);

                Students Student3 = new Students
                {
                    Fname   = "Lavar",
                    Lname   = "Ball",
                    Address = "3 B Baller Way",
                    City    = "Big Ballerville",
                    State   = "CA",
                };
                db.Students.add(Student3);


                Courses Class1 = new Courses
                {
                    Title = "Geometry",
                    CRN   = 102,
                    Dept  = "Math",
                };
                db.Courses.add(Class1);

                Courses Class2 = new Courses
                {
                    Title = "Chemistry",
                    CRN   = 1212,
                    Dept  = "Science",
                };
                db.Courses.add(Class2);

                Courses Class3 = new Courses
                {
                    Title = "Gym",
                    CRN   = 501,
                    Dept  = "Physical Education",
                };
                db.Courses.add(Class3);

                Scores Score = new Scores
                {
                    Type        = "HW",
                    Description = "Estimate your neighbor's WiFi password",
                    Points      = 98,
                    //PointsPossible = 100
                };
                db.Scores.add(Score1);

                Scores Score2 = new Scores
                {
                    Type        = "Quiz",
                    Description = "Fuse 2 Atoms together",
                    Points      = 76,
                    //PointsPossible = 100
                };
                db.Scores.add(Score2);

                Scores Score3 = new Scores
                {
                    Type        = "Exam",
                    Description = "Run a sub 5.0 Second 40 yard dash",
                    Points      = 58,
                    //PointsPossible = 100
                };
                db.Scores.add(Score3);
            }
        }