0
是否有可能將Groupist中的IList映射到GroupViewModel中的IEnumerable?AutoMapper:將模型中的IList映射到IEnumerable中viewModel
型號
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; }
}