ASP .Net用户角色 - 订购下拉列表

时间:2022-12-13 17:05:25

We are using the standard aspnet security features, we have need to set the order of the roles, purely for display purposes.

我们使用标准的aspnet安全功能,我们需要设置角色的顺序,纯粹用于显示目的。

We could just have a sequence number onto the end of the aspnet_roles table, but that feels kinds of hacky to me. Also if in future versions of asp the security get changed we will be in trouble.

我们可以在aspnet_roles表的末尾添加一个序列号,但这对我来说感觉很糟糕。此外,如果在未来的asp版本中安全性发生变化,我们将遇到麻烦。

Is there a better way to do this that won't make me loose sleep each time a new version is pushed out?

有没有更好的方法来做到这一点,每次推出新版本时都不会让我睡不着觉?

1 个解决方案

#1


If you don't want to change the existing schema, store the sequence data in another table and use a custom stored procedure to join the two together and return the values. Use the result of this stored procedure to populate the drop-down.

如果您不想更改现有架构,请将序列数据存储在另一个表中,并使用自定义存储过程将两者连接在一起并返回值。使用此存储过程的结果填充下拉列表。

Don't forget to add a "special case" in the stored procedure to place roles that aren't contained in the second table at a "default" position in the returned set, rather than ignoring them, unless that's desired =)

不要忘记在存储过程中添加“特殊情况”,将第二个表中未包含的角色放在返回集合中的“默认”位置,而不是忽略它们,除非需要=)

#1


If you don't want to change the existing schema, store the sequence data in another table and use a custom stored procedure to join the two together and return the values. Use the result of this stored procedure to populate the drop-down.

如果您不想更改现有架构,请将序列数据存储在另一个表中,并使用自定义存储过程将两者连接在一起并返回值。使用此存储过程的结果填充下拉列表。

Don't forget to add a "special case" in the stored procedure to place roles that aren't contained in the second table at a "default" position in the returned set, rather than ignoring them, unless that's desired =)

不要忘记在存储过程中添加“特殊情况”,将第二个表中未包含的角色放在返回集合中的“默认”位置,而不是忽略它们,除非需要=)