automapper

Automapper exception: “Missing type map configuration or unsupported mapping.”

和自甴很熟 提交于 2019-12-01 15:55:46
I am trying to use Ninject in an ASP.NET MVC 5 application that uses AutoMapper for mapping the Model to the View Model and vice versa. Unfortunately I get an error message that states that the type map configuration is missing. I created a Ninject dependency resolver: namespace MyNamespace.Infrastructure { public class NinjectDependencyResolver: IDependencyResolver { private IKernel kernel; public NinjectDependencyResolver(IKernel kernelParam) { kernel = kernelParam; AddBindings(); } public object GetService(Type serviceType) { return kernel.TryGet(serviceType); } public IEnumerable<object>

AutoMapper with prefix

岁酱吖の 提交于 2019-12-01 15:44:55
I'm trying to use Automapper to map to objects, the issue is one of the objects I'm trying to map has a prefix 'Cust_' in front of all its properties and one doesn't. Is there a way to make this mapping. For example say I have class A { String FirstName { get; set; } String LastName { get; set; } } class B { String Cust_FirstName { get; set; } String Cust_LastName { get; set; } } Obviously this map won't work AutoMapper.Mapper.CreateMap<A, B>(); b = AutoMapper.Mapper.Map<A, B>(a); Mapper.Initialize(cfg => { cfg.RecognizeDestinationPrefixes("Cust_"); cfg.CreateMap<A, B>(); }); A a = new A()

Automapper exception: “Missing type map configuration or unsupported mapping.”

隐身守侯 提交于 2019-12-01 15:33:05
问题 I am trying to use Ninject in an ASP.NET MVC 5 application that uses AutoMapper for mapping the Model to the View Model and vice versa. Unfortunately I get an error message that states that the type map configuration is missing. I created a Ninject dependency resolver: namespace MyNamespace.Infrastructure { public class NinjectDependencyResolver: IDependencyResolver { private IKernel kernel; public NinjectDependencyResolver(IKernel kernelParam) { kernel = kernelParam; AddBindings(); } public

How to automap this(mapping sub members)

大城市里の小女人 提交于 2019-12-01 15:24:20
I have something like this public class ProductViewModel { public int SelectedProductId { get; set; } public string ProductName {get; set;} public int Qty {get; set;} public List<SelectListItem> Products { get; set}; } I have a domain like this public class Product { public int ProductId {get; set;} public string ProductName {get; set;} public int Qty {get; set;} } public class Store { public Product() {get; set;} } Now I need to do the mapping. // in my controller var result = Mapper.Map<ProductViewModel, Store>(Product); this won't bind anything since it can't figure out how to put the

How to automap this(mapping sub members)

你。 提交于 2019-12-01 14:24:30
问题 I have something like this public class ProductViewModel { public int SelectedProductId { get; set; } public string ProductName {get; set;} public int Qty {get; set;} public List<SelectListItem> Products { get; set}; } I have a domain like this public class Product { public int ProductId {get; set;} public string ProductName {get; set;} public int Qty {get; set;} } public class Store { public Product() {get; set;} } Now I need to do the mapping. // in my controller var result = Mapper.Map

automapper Missing type map configuration or unsupported mapping.?

谁说我不能喝 提交于 2019-12-01 14:13:42
问题 ERROR Missing type map configuration or unsupported mapping. Mapping types: Cities_C391BA93C06F35100522AFBFA8F6BF3823972C9E97D5A49783829A4E90A03F00 -> IEnumerable`1 System.Data.Entity.DynamicProxies.Cities_C391BA93C06F35100522AFBFA8F6BF3823972C9E97D5A49783829A4E90A03F00 -> System.Collections.Generic.IEnumerable`1[[OsosPlus2.Core.DataAccess.Cities, OsosPlus2.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] Destination path: CustomerViewModel.Cities.Cities Source value: System.Data

AutoMapper with prefix

ⅰ亾dé卋堺 提交于 2019-12-01 13:51:36
问题 I'm trying to use Automapper to map to objects, the issue is one of the objects I'm trying to map has a prefix 'Cust_' in front of all its properties and one doesn't. Is there a way to make this mapping. For example say I have class A { String FirstName { get; set; } String LastName { get; set; } } class B { String Cust_FirstName { get; set; } String Cust_LastName { get; set; } } Obviously this map won't work AutoMapper.Mapper.CreateMap<A, B>(); b = AutoMapper.Mapper.Map<A, B>(a); 回答1: Mapper

Data Entities > Domain Objects > ViewModels, each with drastically different data structures

半世苍凉 提交于 2019-12-01 13:12:36
问题 This is sort of a generic question in regards to mapping between data entities, domain objects, and ViewModels. I may not be asking it right but hopefully I can make some sense of it. Below is a simplified problem. Pretend I have an Entity Framework model which maps 1:1 to my database tables, but my domain objects may not be identical, and my ViewModel is drastically different again. As a pseudo-example: Database/EF Entities: MembershipAccount MembershipAccountExtraInfo Domain: Account

Where to place AutoMapper map registration in referenced dll

人走茶凉 提交于 2019-12-01 11:15:51
This is my first AutoMapper project and may be obvious to some but the tutorials and examples are not clicking with me. I am trying to understand where and to a certain degree how to register(I think I want profiles) my maps for use. There are plenty of MVC examples saying to use the global asax and this makes sense but what is the equivalent in a library project? In my sandbox I have a winform app and a core library. The winform app calls methods made available by the library and it is one of these library methods that makes use of automapper. So for some background here is my map: (and to be

Automapper, MapFrom and EF dynamic proxies

泪湿孤枕 提交于 2019-12-01 09:34:49
I have been trying to map my domain objects to a report view model. Things all worked well in testing where I faked the entity framework code out and used a builder to return a fully populated pocco object. Now that I am actually hitting the database and returning data I am seeing some wierd dynamic proxy type errors. Here is a sample of my code: public class ContactMapping : Profile { protected override void Configure() { Mapper.CreateMap<Contact, ReportRowModel>() .ForMember(dest => dest.Gender, opt => opt.MapFrom(src => src.Gender.Name)); } } And the mapping code is like this: var contact =