How to update one field of specific records using Entity Framework?

前端 未结 6 1387
别跟我提以往
别跟我提以往 2021-01-31 11:10

I want update family of a person who his name is pejman. This is my object Class:

public class Person
{
    public int Id { get; set; }
    public string FirstNa         


        
6条回答
  •  一整个雨季
    2021-01-31 11:33

    Any Object This makes Easier to update.

    using (var db = new DBContext())
            {
                AppUser au = new AppUser()
                {
                    AppUserId = (int)txtID.Content,
                    UserName = txtUserName.Text,
                    Password = txtPwd.Password.ToString(),
                db.Entry(au).State= EntityState.Modified;
                db.SaveChanges();
            }
    

提交回复
热议问题