c# - CreateMap for IEnumerable -


i have automapper profile , while working senior developer gave me pointer create map ienumerable, got coded stuck.

i tried this

createmap<ienumerable<businessinfo>, ienumerable<adminviewmodel.account>>().forallmembers(i => i.ignore()); createmap<ienumerable<businessinfo>, ienumerable<adminviewmodel.account>>()                 .formember(i => i.company, opt => opt.mapfrom(p => p.company)) 

but company errored because doesn't contain definition company... think missing unsure is.

why mapping ienumerable<type>? reason why doesn't contain definition of company because it's collection.

you of mapping businessinfo , adminviewmodel.account.

mapper.createmap<businessinfo, adminviewmodel.account>()... // usual or w/e custom mapping want. 

then like...

var adminaccountviewmodel = mapper.map<ienumerable<businessinfo>, ienumerable<adminviewmodel.account>>(businessinfo); 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -