this my modelview .
public class RoleAccess
{
public int id { get; set; }
public string name { get; set; }
public List<ChildRole> children { get; set; }
}
and this is ChildRole :
public class ChildRole
{
public int id { get; set; }
public int parentid { get; set; }
public string name { get; set; }
}
now i need to fill view model with this code :
public List<RoleAccess> SubRole()
{
List<RoleAccess> sub = new List<RoleAccess>();
foreach (var parent in Roles.Where(x => x.Id == 0))
{
foreach (var child in Roles.Where(x=>x.RoleLevel==parent.Id))
{
sub.Select(role=>new RoleAccess
{
id = parent.Id,
name = parent.Description,
children=child
});
}
}
return sub;
}
but it show me this error in this line :
Cannot implicitly convert type 'StoreFinal.Entities.Entities.Identity.Role' to 'System.Collections.Generic.List
How Can i solve This Problem ????
Aucun commentaire:
Enregistrer un commentaire