1

I have View Model and Class that I have to map. This is my maping setting:

Mapper.CreateMap<ViewModels.objTest, clsTest>().ReverseMap();

I have to map List of View model to my clsTest.

for now I'm using looping like this:

List<clsTest> objListResult = new List<clsTest>();
if (List<objTest> != null)
{
    foreach (var item in objTest)
    {
        objListResult.Add(Mapper.Map<objTest, clsTest>(item));
    }
}

Its work fine, but is there anyway to map faster than this? Maybe is there any way mapping from List to List even my setting like above?

Thank you

1 Answer 1

3

You can just call Map with the list...

List<objTest> objListResult = Mapper.Map<List<clsTest>, List<objTest>>(objTest);

As you can see in documentation: http://automapper.codeplex.com/wikipage?title=Lists%20and%20Arrays

Sign up to request clarification or add additional context in comments.

1 Comment

this is the answer I really need!! thank you for giving me the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.