错误:已有打开的与此 Command 相关联的 DataReader,必须首先将它关闭
原代码:
public void UpdatePermissionUserTypeByRightID(int rightID, string userTypes) { var targetList = ListAll().Where(s => s.rightID == rightID); foreach (var item in targetList) { item.permissionUserType = userTypes; //注意,如果子节点可见,则父节点一定可见 //修改父节点权限,如果有父节点的话,注意要避免父节点中的角色ID重复 if (item.parentID > 0) { MenuNodes parent1 = getByID(item.parentID); string tempPUserTypes = JimShared.GetNoOverlapStr(item.permissionUserType, parent1.permissionUserType); parent1.permissionUserType = tempPUserTypes; } } //!提交数据 commit(); }
修改后:(只是加了一个tolist())
public void UpdatePermissionUserTypeByRightID(int rightID, string userTypes) { var targetList = ListAll().Where(s => s.rightID == rightID).ToList(); foreach (var item in targetList) { item.permissionUserType = userTypes; //注意,如果子节点可见,则父节点一定可见 //修改父节点权限,如果有父节点的话,注意要避免父节点中的角色ID重复 if (item.parentID > 0) { MenuNodes parent1 = getByID(item.parentID); string tempPUserTypes = JimShared.GetNoOverlapStr(item.permissionUserType, parent1.permissionUserType); parent1.permissionUserType = tempPUserTypes; } } //!提交数据 commit(); }