c# EF增删改查

public int Add(UserInfo user)
        {
            db.UserInfo.Add(user);
            return db.SaveChanges();
        }
        // post
       
        public int Edit(UserInfo user)
        {
            db.Entry<UserInfo>(user).State = System.Data.Entity.EntityState.Modified;
            return db.SaveChanges();
        }
        // post
       
        public int Remove(int id)
        {
            var user = db.UserInfo.Find(id);
            db.UserInfo.Remove(user);
            return db.SaveChanges();
        }
        // get
        public List<UserInfo> GetAll()
        {
            return db.UserInfo.ToList();
        }
        // 根据ID获取用户
        public UserInfo GetUserById(int Id)
        {
            return db.UserInfo.Find(Id);
        }

c# EF增删改查

上一篇:window10 anaconda 下 tensorflow2.1+keras+pytorch


下一篇:Win10家庭版启用组策略gpedit.msc