Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4108410
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:39:04+00:00 2026-05-20T21:39:04+00:00

I have a simple mapping and it is working but it’s not filling in

  • 0

I have a simple mapping and it is working but it’s not filling in Output.Details.

I am a bit confused, I think it maybe because I am using the source as "Task" for each one.

  Mapper.CreateMap<Task, Output>();


  Mapper.CreateMap<Task, Output.Details>().ForMember(
       dest => dest.Item, opt => opt.MapFrom(src => src.Name));

As far as i know i have to create 2 maps, 1 for the object and 1 for object contained within.

Problem is the source for the OUTPUT and OUTPUT.DETAILS can be found in TASK

I tried delving into Details within the first map and specifying Mapfrom but it gives the following error which is why i must create 2 maps

         must resolve to top-level member. Parameter name: lambdaExpression error

  IList<Task> tempItems= GetItems();

        IList<Output> items =
            Mapper.Map<IList<Task>, IList<Output>>(tempItems);

The map works but my property "Item" availble in Output.Details is NULL

What am I doing wrong? Here is my Destination object.

It fills in Name no problem, but nothing inside DETAILS… they are left NULL.

Task is not my class, but I checked it and all values are there to be copied hence Tag has a value and is a STRING.

public class Output   
{
    public string Name { get; set; }

    public Details Summary { get; private set; }
 
    public class Details
    {
        public string Item{ get; set; }
    }

    public Output()
    {
        Summary = new Details();
    }
}

EDIT

Here is an example of the Task class.

enter image description here

EDIT

They is a sample vs 2010 project here and it shows exactly the problem.

http://dl.dropbox.com/u/20103903/AutomapperNotWorking.zip

and here is an image showing the issue, as you can see Summary Item is "NULL" but it should contain the NAME from Task.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:39:05+00:00Added an answer on May 20, 2026 at 9:39 pm

    First off, always use Mapper.AssertConfigurationIsValid(); to make sure your mapping configuration is valid. I added it to your code and it immediately highlighted the problem: You didn’t tell Automapper what to do with the Summary property. Since Task doesn’t contain a property called Summary, Automapper needs to know what to do with it.

    So the problem isn’t really how to map a nested class, you just need to tell Automapper what to do with Summary. Here’s the Automapper configuration that works for your example:

    Mapper.CreateMap<Task, Output>()
        .ForMember(d => d.Summary, o => o.MapFrom(t => new Output.Details {Item = t.Name}));
    Mapper.AssertConfigurationIsValid();
    

    That’s all you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have what I think should be a fairly simple mapping issue, but not
I have a project that I have recently started working on seriously but had
I am missing something obvious, but I'm not sure what. I have a single
I am missing something obvious, but I'm not sure what. I have a single
I'm working on converting a rather large (but somewhat simple) app from Symfony to
I'm working in OpenCV but I don't think there is a function for this.
I have a very simple Mapping I'm trying to do. I'm following the NHibernate
I have simple win service, that executes few tasks periodically. How should I pass
i have simple regular expression: ^123$ Matches are for example 123 1234 etc. How
I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.