public void UpdateSysRoleSysUser(string userId, string[] roleIds) { using (AppDBContainer db = new AppDBContainer()) { db.P_Sys_DeleteSysRoleSysUserByUserId(userId); foreach (string roleid in roleIds) { if (!string.IsNullOrWhiteSpace(roleid)) { db.P_Sys_UpdateSysRoleSysUser(roleid, userId); } } db.SaveChanges(); } }