Beispiel #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int            id = 1;
            MagnumEntities db = new MagnumEntities();
            User           u  = db.Users.FirstOrDefault(x => x.ID == id);

            db.Users.Remove(u);

            db.SaveChanges();
        }
Beispiel #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            MagnumEntities db = new MagnumEntities();
            User           u  = new User();

            u.Name = TextBox1.Text;

            db.Users.Add(u);
            db.SaveChanges();
        }
Beispiel #3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            int            id = 1;
            MagnumEntities db = new MagnumEntities();
            User           u  = db.Users.Find(id);

            if (u == null)
            {
            }
            else
            {
                u.Name = "KK";
                db.SaveChanges();
            }
        }