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 7897611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:12:38+00:00 2026-06-03T08:12:38+00:00

In some cases there is a need to return composite DTOs from our repository,

  • 0

In some cases there is a need to return composite DTOs from our repository, where the DTO just has a few properties that are Model properties and the function of the DTO is just to be a simple composite object (returning a Queryable is not enough because there is more information than T)

For example:

Model:

public class Job
{
    int Id { get; set; }
    //more properties
}

public class JobApplication
{
    int Id { get; set; }
    //more properties
}

Repository:
IQueryable<JobAndUserApplication> GetJobAndMatchingUserApplication(int userId):

public class JobAndUserApplication
{
    public Job Job { get; set; }
    public JobApplication JobApplication { get; set; }
}

Now – Id like to simply do (Project and To are Automapper functionality):

//this allows one efficient query to bring in the subproperties of the composite DTO    
var jobVmList = jobRepository.GetAllJobsAndMatchingJobApplicationByUser(userId)              
                             .Project()
                             .To<JobVM>()
                             .ToList();

So I need a mapping kind of like this:

Mapper.CreateMap<JobAndUserApplication, JobVM>()
      .ForMember(jvm => jvm, opt => opt.ResolveUsing(src => src.Job));
      //many other .ForMembers that are not relevant right now

I am attempting to map the Job property of the DTO directly on to the JobVM (which shares many of the same properties).

My mapping throws the following exception:

Custom configuration for members is only supported for top-level individual members on a type.

What am I doing wrong and how can I accomplish the mapping form the Job property of the DTO on the the JobVM itself?

Thanks

  • 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-06-03T08:12:39+00:00Added an answer on June 3, 2026 at 8:12 am

    Automapper is telling you that you can only define custom actions on a member (property) of a class, not on the class itself. What you need to do is first create a Job to JobVM map:

    Mapper.CreateMap<Job, JobVM>()
    

    and

    Mapper.CreateMap<JobAndUserApplication, JobVM>()
    

    being sure to ignore and set any duplicate properties across the two types. Then run automapper twice, first from the child object:

    var jobVM = Mapper.Map<Job, JobVM>(jobAndUserApplication.job);
    

    then from the parent object

    Mapper.Map<JobAndUserApplication, JobVM>(jobAndUserApplication, jobVM );
    

    Or the other way around, depending on how your properties are laid out.

    Quick side note: I have a feeling you might be mixing concerns, and my code smell alarm is going off. I’d take a second look at either your viewmodel or domain model, as this is not a typical issue I see come up. (just my $0.02 🙂

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

Sidebar

Related Questions

I have a function that needs to return NULL in some cases and there
I need to have a formula produce a null in some cases, numeric in
We are using Entity Framework 1.0. In some cases we need to explicitly open
I am using iText to write a PDF. In some cases, I need to
I have a TextBox that has the TextChanged event set declaratively. In some cases,
In some special cases you will need a list of textboxes (to deal with
In the app we're developing using Django, in some cases we need to automatically
I have a checkbox which in some cases may be disabled and checked using
In what cases does capitilization affect a url? In some cases they seem to
I am using jquery cluetip and i have noticed taht in some cases the

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.