是否可以将 Group 中的 IList 映射到 GroupViewModel 中的 IEnumerable?
模型
public class Group
{
public string Name { get; set; }
public virtual IList<Permission> Permissions
{
get { return _permissoes ?? (_permissions = new List<Permission>()); }
set { Permissoes.Clear(); _permissions = value; }
}
}
public class Permission
{
public long Id { get; set; }
public string Name { get; set; }
}
视图模型
public class GroupViewModel
{
public string Name { get; set; }
public IEnumerable<PermissionViewModel> Permissions { get; set; }
}
public class PermissionViewModel
{
public int Id { get; set; }
public string Name { get; set; }
}