asp.net mvc 4 - AutoMapper not working **Probably failing for navigation properties** -
i have 2 classes:
class - country >> id, name, list
class - city >> id, name, countryid, country
i have countryviewmodel , cityviewmodel classes identical above classes.
i have written following in global.asax.cs:
automapper.mapper.createmap<country,countryviewmodel>(); automapper.mapper.createmap<city,cityviewmodel>();
after retrieving entities datbabse, firing following line map models view models.:
automapper.mapper.map(country, system.type.gettype("country"), system.type.gettype("countryviewmodel"));
this giving "object reference not found" error on above line.
make sure global.asax.cs includes call
automapper.mapper.assertconfigurationisvalid()
make sure mapped properly.i've never used non-generic syntax
map
before, generic version should work is:automapper.mapper.map<country, countryviewmodel>(country);
Comments
Post a Comment