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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:10:18+00:00 2026-05-17T20:10:18+00:00

I’m considering to use AutoMapper in the upcoming project and trying to find possible

  • 0

I’m considering to use AutoMapper in the upcoming project and trying to find possible “bottlenecks”. At the moment the most complex case i can imagine is the following:
A domain class which is represented by 3 (for example) tables in the database (my data access layer is LINQ to SQL). To build an instance of the class i need to perform 3 queries:

  1. Select by ID from table A (1 row, goes directly to Class properties)
  2. Select by ID from table B (0..1 rows, goes to optional Class.Code property)
  3. Select by ID from table C (0..N rows, goes to Class.Parameters collection)

And i’m not sure how to configure the mapping. Here are the options i considered:

  1. Perform 3 queries and map Tuple<A,B,C> -> Class
  2. Combine queries 1 and 2 using outer join (more effective). But what do i do with anonymous type?
  3. Inject datacontext into the mapping, define A -> Class mapping and let the type converters do the job?

None looks like a win. What would you suggest?

Edit: Well, such complex cases is quite rare (10-20%) and i can do them manually and the rest 80-90% with AutoMapper just fine. But i’d like to know if AutoMapper is not designed for such strategies or i’m missing something important.

  • 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-17T20:10:19+00:00Added an answer on May 17, 2026 at 8:10 pm

    Your question is difficult to answer because how and where a domain object get its data is not the concern of AutoMapper. From the AutoMapper documentation:

    AutoMapper is geared towards model
    projection scenarios to flatten
    complex object models to DTOs and
    other simple objects, whose design is
    better suited for serialization,
    communication, messaging, or simply an
    anti-corruption layer between the
    domain and application layer.

    However, this doesn’t mean that your use of AutoMapper shouldn’t factor into the thought process behind your domain objects. As an example lazy loading springs to mind. For instance in your case if you used lazy loading on the Class.Parameters property, but then ran that property through AutoMapper the data would always be loaded. That’s why it’s important to stick to the rule of one model per view.

    Jimmy Bogard one of the creators of AutoMapper discusses his vision for what AutoMapper is in AutoMapper: the Object-Object Mapper. I wish I could link directly to it but in a comment reply on the aforementioned post Bogard states:

    That’s something we’ve looked at for a
    while (two-way binding), but in the
    end, we found that there was just too
    much business validation in an Update.

    Instead, we formed other patterns
    around updating a model from a
    message/form. See Code Camp Server
    source for more details.

    As indicated you can find heavy use of AutoMapper in the source for CodeCampServer. A simplified version of the CodeCampServer code can be found in the source code provided with ASP.NET MVC 2 in Action.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

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.