Exemple #1
0
        private static void InsertStudent()
        {
            var s1 = new Student()
            {
                Id       = Guid.NewGuid(),
                Name     = "Akash",
                Cgpi     = "8.6",
                Location = "Mumbai"
            };
            var s2 = new Student()
            {
                Id       = Guid.NewGuid(),
                Name     = "Dhruv",
                Cgpi     = "9.6",
                Location = "MiraRode"
            };
            var s3 = new Student()
            {
                Id       = Guid.NewGuid(),
                Name     = "Sanal",
                Cgpi     = "9.8",
                Location = "Raigad"
            };

            db.Students.Add(s1);
            db.Students.Add(s2);
            db.Students.Add(s3);
            db.SaveChanges();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //  Create();

            //  ienumerableQuery();


            //  Update();

            //var deleteQuery = dbcontext.Students.First<Student>();
            //dbcontext.Students.Remove(deleteQuery);
            //dbcontext.SaveChanges();

            var stud = dbcontext.Students.Find("176ED643 - 3FF4 - 4130 - 989A - 192FAE877C42");

            dbcontext.Students.Remove(stud);
            dbcontext.SaveChanges();
        }
        private static void UpdateOPeration(SwabhavEFDBContext db)
        {
            var student = db.Students.Where((student1) => student1.Name.Equals("SANAL"));

            foreach (Student stud in student)
            {
                stud.CGPA = 9.5f;
            }
            db.SaveChanges();
            Console.WriteLine("Data updated!");
        }
        private static void DeleteOpertion(SwabhavEFDBContext db)
        {
            var student = db.Students.Where((student1) => student1.Name.Equals("MANISH"));

            foreach (Student stud in student)
            {
                db.Students.Remove(stud);
            }
            db.SaveChanges();
            Console.WriteLine("Data deleted!");
        }
        private static void InsertOPeration(SwabhavEFDBContext db)
        {
            db.Students.Add(new Student {
                Id = Guid.NewGuid(), Name = "MANISH", CGPA = 8f
            });
            db.Students.Add(new Student {
                Id = Guid.NewGuid(), Name = "AKASH", CGPA = 8.5f
            });
            db.Students.Add(new Student {
                Id = Guid.NewGuid(), Name = "SANAL", CGPA = 7.5f
            });

            db.SaveChanges();
            Console.WriteLine("Data Saved!");
        }