ViewModel To Model使用ExpressMapper List <object>将List <model>列为Field

时间:2016-02-15 00:12:06

标签: 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 string Name { get; set; }

    public int ProductId { get; set; }

    [ForeignKey("ProductId")]
    public virtual Product Product { get; set; }
}

View Model Is:

public class ProductViewModel
{
    public int id { get; set; }
    public string Name { get; set; }
    public string Color { get; set; }
    public List<string> Tags { get; set; }
}

我正在使用ExpressMapper To Mapping。 它可以映射productviewModel列表标签到公共ICollection标签吗?

1 个答案:

答案 0 :(得分:0)

您可以注册这样的映射:

URL

以下是工作示例:https://dotnetfiddle.net/2r7l4z