我正在尝试获取在 NOPCOMMERCE 中分配给用户的所有角色。我知道如何确定用户是否具有特定角色,但我无法获取列表或列表框中的所有角色。
如果我使用以下代码:
Imports Nop.Core.Infrastructure
Imports Nop.Services.Helpers
Imports Nop.Core.Domain.Customers
Imports Nop.Services.Customers
Imports Nop.Core
ListBox1.DataSource = EngineContext.Current.Resolve(Of IWorkContext)().CurrentCustomer.CustomerRoles()
ListBox1.DataBind()
'this is the listbox on aspx page
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
我在列表框中得到了这个:
System.Data.Entity.DynamicProxies.CustomerRole_6E0DFC682B2D3247B3BEEED3063345A95D5742CE33B2761C4CB20A8C0A0AD639
System.Data.Entity.DynamicProxies.CustomerRole_6E0DFC682B2D3247B3BEEED3063345A95D5742CE33B2761C4CB20A8C0A0AD639
System.Data.Entity.DynamicProxies.CustomerRole_6E0DFC682B2D3247B3BEEED3063345A95D5742CE33B2761C4CB20A8C0A0AD639
System.Data.Entity.DynamicProxies.CustomerRole_6E0DFC682B2D3247B3BEEED3063345A95D5742CE33B2761C4CB20A8C0A0AD639
其中显示了 4 个角色,但它们在我看来不像角色。我需要实际的角色名称。有谁知道我如何获得用户拥有的所有角色?谢谢。