2

I have the following class and interface definitions, and would like to use EmitMapper instead of AutoMapper to map from class to interface. The current code works, but I'd like to use EmitMapper, yet have not figured out how to use it.

public interface  ITreeViewDTO
{
    int Id { get; set; }
    string Name { get; set; }
    int? Parent_Id { get; set; }
    string ExtraData { get; set; }
    IEnumerable<ITreeViewDTO> SubNode { get; set; }
}

public class Navigation
{
    public int Id { get; set; }
    public string Name{ get; set; }
    public int? Parent_Id { get; set; }
    public virtual IList<Navigation> SubNavigations { get; set; }
}

This is the current AutoMapper configuration for the desired mapping:

Mapper.CreateMap<Navigation, ITreeViewDTO>()
   .ForMember(dest => dest.SubNode, 
              opt => opt.MapFrom<IEnumerable<Navigation>>(src => src.SubNavigations));
var iTreeView = Mapper.Map<Navigation, ITreeViewDTO>(root);

What would be the equivalent EmitMapper code for the above sample?

Morten Mertner
  • 9,414
  • 4
  • 39
  • 56
ARA
  • 53
  • 10
  • 1
    It might just be me, but I have no clue what you are asking.. – Morten Mertner Apr 03 '13 at 20:45
  • i use from auto mapper for map navigation class to interface iTreeViewDTO ! All things is Ok, but i want use emit mapper instance auto mapper ! – ARA Apr 05 '13 at 10:28
  • Sorry, just after some clarification to your question. Are you saying you want to use [EmitMapper](https://emitmapper.codeplex.com/) instead of [AutoMapper](https://github.com/AutoMapper/AutoMapper), and you want a hand to convert your code? – Mightymuke Apr 05 '13 at 21:47
  • thank you man , i want this exactly – ARA Apr 09 '13 at 16:40

0 Answers0