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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:21:44+00:00 2026-06-13T12:21:44+00:00

I have a model that is my base model that has numerous fields in

  • 0

I have a model that is my base model that has numerous fields in it. I then have 4 DTOs that are parts of that model. I want to map all of them to the model in the end but each time I map it overwrites the previous mapping.

For example

_model = new GenericModel();
_model.ExampleNotInDTO = "This Gets Overwritten being set previously";

//First Mapping below overwrites the property I set above and 
// sets only the fields in the business dto.
Mapper.CreateMap<BusinessDto, GenericModel>();
_model = Mapper.Map<BusinessDto, GenericModel>(searchResultsQuery.BusinessDto);

//Now doing another mapping just below it nulls out all the previous 
// stuff and only fills in the events dto.
Mapper.CreateMap<EventsDto, GenericModel>();
_model = Mapper.Map<EventsDto, GenericModel>(searchResultsQuery.EventsDto);

How would be the best way to get all 4 of my dtos (only 2 above for example sake) into the same _model object?

  • 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-13T12:21:45+00:00Added an answer on June 13, 2026 at 12:21 pm

    You’re asking AutoMapper to create a new object each time when you call Map that way. You can create the object manually and use Map<TSource, TDestination>(TSource source, TDestination destination) to do what you want. For example:

    Mapper.Map<BusinessDto, GenericModel>(searchResultsQuery.BusinessDto, _model);
    

    or

    Mapper.Map(searchResultsQuery.BusinessDto, _model);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model class that has, among other things: class Group < ActiveRecord::Base
I have a user model that has many carts class User < ActiveRecord::Base has_many
I have a model that has an image attached to it that I want
I have a base model that I extend from. In it, I have defined
I have a model that has a ForeignKey to the built-in user model in
I have a model that has an amount and I'm tracking to see if
I have an entity model that has audit information on every table (50+ tables)
I have a TakeAction model that looks like this: class TakeAction < ActiveRecord::Base belongs_to
I have a simple model class Ad < ActiveRecord::Base has_many :ad_items end class AdItem
I have a model that has amenities with a 1:1 relationship: class Listing <

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.