예제 #1
0
        // CRUD - CREATE, READ, UPDATE, DELETE

        static void CreateNewUser()
        {
            using var context = new MyDatabaseContext();
            var newUser = new User {
                Name = "Raja", Email = "*****@*****.**"
            };

            context.Users.Add(newUser);
            context.SaveChanges();
        }
예제 #2
0
        static void UpdateUserEmail(int id, string email)
        {
            using var context = new MyDatabaseContext();
            var user = context.Users.Find(id);

            if (user != null)
            {
                user.Email = email;
            }
            context.SaveChanges();
        }