Holla,
I have an data access object as follows:
class Foo : IStorable
{
string name;
int age;
.. many more
}
I have another object like this:
class FooViewModel
{
Foo data;
Bar moreData;
Car evenMore
}
So i m reading Foo object from database and i have to construct a ViewModel. ViewModel has a Foo object and some other objects as well. I want to map Foo to ViewModel’s Foo.
How can i map this with AutoMapper?
Mapper.CreateMap<Foo, FooViewModel>();
Would this work? and how would I access get it?
Essentially i have classes with many properties, i want to avoid typing (being lazy)
The FooViewModel should have all of the properties of Foo that you would like to map, not a ‘Foo’ property.
Then, you will be able to use AutoMapper to map Foo to FooViewModel and any relational dependencies that Foo has will not end up in the FooViewModel.