private void Run() { Customer customer = GetCustomerFromDB(); CustomerViewItem customerViewItem = Mapper.Map <Customer, CustomerViewItem>(customer); ShowCustomerInDataGrid(customerViewItem); }
static void Main(string[] args) { Mapper.Initialize(cfg => cfg.CreateMap <Customer, CustomerViewItem>()); var cus = GetAllCustomers(); var cusf = GetAllCustomers().FirstOrDefault(); var config = new MapperConfiguration(cfg => cfg.CreateMap <Customer, CustomerViewItem>()); var mapper = new Mapper(config); CustomerViewItem dto = Mapper.Map <CustomerViewItem>(cus); var dest = Mapper.Map <Customer, CustomerViewItem>(cusf, opt => opt.ConfigureMap().ForMember(x => x.FullName, m => m.MapFrom(src => src.FirstName))); IEnumerable <CustomerViewItem> ienumerableDest = Mapper.Map <List <Customer>, IEnumerable <CustomerViewItem> >(cus); ICollection <CustomerViewItem> icollectionDest = Mapper.Map <List <Customer>, ICollection <CustomerViewItem> >(cus); IList <CustomerViewItem> ilistDest = Mapper.Map <List <Customer>, IList <CustomerViewItem> >(cus); List <CustomerViewItem> listDest = Mapper.Map <List <Customer>, List <CustomerViewItem> >(cus); CustomerViewItem[] arrayDest = Mapper.Map <Customer[], CustomerViewItem[]>(cus.ToArray()); }
private void ShowCustomerInDataGrid(CustomerViewItem customerViewItem) { }