0
我有以下方法:如何退還的IList <T>自ICollection <T>
public Task<IList<string>> GetRolesAsync(AppUser user)
{
if(user.Roles == null)
{
// TODO: Load roles
}
//Not sure return syntax to return user.Roles as IList<string>
return Task.FromResult<List<string>>(???);
}
凡user.Roles
的類型ICollection<IAppRole>
以上的回報類型的IList<string>
方法。我無法進行轉換,然後找到合適的語法來完成轉換。
你怎麼能指望'IAppUser'轉成'string'? – i3arnon
這是我的問題中的一個錯誤,我剛剛糾正了,IAppUser應該是IAppRole,該方法將採取角色的集合並將它們作爲字符串值列表(只是名稱)返回這是一個Identity 2 UserStore自定義商店實現。 – Richard
那麼爲什麼不用'List'來代替呢? –
DavidG