Mvvm ViewModel到Model使用ExpressMapper列表<;对象>;列出<;模型>;as场

Mvvm ViewModel到Model使用ExpressMapper列表<;对象>;列出<;模型>;as场,mvvm,mapping,automapper,Mvvm,Mapping,Automapper,我的模型是: public class Product { public int id { get; set; } public string Name { get; set; } public string Color { get; set; } public ICollection<Tag> Tags { get; set; } } public class Tag { public int id { get; set; }

我的模型是:

 public class Product
{
    public int id { get; set; }
    public string Name { get; set; }
    public string Color { get; set; }
    public ICollection<Tag>  Tags { get; set; }
}

 public class Tag
{
    public int id { get; set; }
    public string Name { get; set; }

    public int ProductId { get; set; }

    [ForeignKey("ProductId")]
    public virtual Product Product { get; set; }
}
公共类产品
{
公共int id{get;set;}
公共字符串名称{get;set;}
公共字符串颜色{get;set;}
公共ICollection标记{get;set;}
}
公共类标签
{
公共int id{get;set;}
公共字符串名称{get;set;}
public int ProductId{get;set;}
[外键(“产品ID”)]
公共虚拟产品产品{get;set;}
}
视图模型为:

public class ProductViewModel
{
    public int id { get; set; }
    public string Name { get; set; }
    public string Color { get; set; }
    public List<string> Tags { get; set; }
}
公共类ProductViewModel
{
公共int id{get;set;}
公共字符串名称{get;set;}
公共字符串颜色{get;set;}
公共列表标记{get;set;}
}
我正在使用ExpressMapper进行映射。
是否可以将productviewModel列表标记映射到公共ICollection标记?

您可以这样注册映射:

 Mapper.RegisterCustom<Tag, string>((tag) => tag.Name);
            Mapper.Register<Product, ProductViewModel>();
            Mapper.Compile();
Mapper.RegisterCustom((tag)=>tag.Name);
Register()映射器;
Compile();
下面是一个工作示例: