LINQ更新用户
public Boolean UpdateUser(int id, string userName, string account, string password, string EkeyID, int userType,int companyid ,Role ro)
{
var result = (from c in _context.Users.Include("Roles") where c.UserId == id select c).FirstOrDefault();
//var result = _context.Users.SingleOrDefault<User>(c => c.UserId == id);
_context.Entry(result).State = System.Data.EntityState.Modified;
result.UserName = userName;
result.Account = account;
result.Password = password;
result.EkeyID = EkeyID;
// result.CompanyName = PublicKey;
result.UserType = userType;
result.CompanyId = companyid;
result.Roles = new List<Role>();
result.Roles.Add(ro);
//_context.Set<User>().Add(entity);
_context.SaveChanges();
return true;
}