I'm trying to use Automapper v3 to map from my Post struct to my Postmodel class. I need to map Term Name to my Categories array but only if the Type equals "Category".
Here's my code
public class NewsModel
{
public NewsModel(int id)
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Post, PostModel>();
});
Posts = new List<PostModel> {Mapper.Map<PostModel>(_newsGetter.GetItem(id))};
}
public List<PostModel> Posts { get; set; }
}
Map to this class
public class PostModel
{
public String[] Categories { get; set; }
}
Map from this Struct
public struct Post
{
public Term[] Categories { get; set; }
}
public Struct Term
{
public string Name{ get; set; }
public string Type{ get; set; }
}
Any help is greatly appreciated.