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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:21:08+00:00 2026-05-25T10:21:08+00:00

I have recently started evaluating Dapper as a potential replacement for EF, since I

  • 0

I have recently started evaluating Dapper as a potential replacement for EF, since I was not too pleased with the SQL that was being generated and wanted more control over it. I have a question regarding mapping a complex object in my domain model. Let’s say I have an object called Provider, Provider can contain several properties of type IEnumerable that should only be accessed by going through the parent provider object (i.e. aggregate root). I have seen similar posts that have explained using the QueryMultiple and a Map extension method but was wondering how if I wanted to write a method that would bring back the entire object graph eager loaded, if Dapper would be able to do this in one fell swoop or if it needed to be done piece-meal. As an example lets say that my object looked something like the following:

public AggregateRoot
      {
           public int Id {get;set;}
           ...//simple properties
           public IEnumerable<Foo> Foos
           public IEnumerable<Bar> Bars
           public IEnumerable<FooBar> FooBars
           public SomeOtherEntity Entity
           ...
      }

Is there a straightforward way of populating the entire object graph using Dapper?

  • 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-25T10:21:09+00:00Added an answer on May 25, 2026 at 10:21 am

    I have a similar situation. I made my sql return flat, so that all the sub objects come back. Then I use the Query<> to map the full set. I’m not sure how big your sets are.

    So something like this:

    var cnn =  sqlconnection();
    
    var results = cnn.Query<AggregateRoot,Foo,Bars,FooBar,someOtherEntity,AggregateRoot>("sqlsomething"
                    (ar,f,b,fb,soe)=>{
                        ar.Foo = f;
                        ar.Bars = b;
                        ar.FooBar = fb;
                        ar.someotherentity = soe;
                        return ar;
    
                    },.....,spliton:"").FirstOrDefault();
    

    So the last object in the Query tag is the return object. For the SplitOn, you have to think of the return as a flat array that the mapping will run though. You would pick the first return value for each new object so that the new mapping would start there.

    example:

    select ID,fooid, foo1,foo2,BarName,barsomething,foobarid foobaritem1,foobaritem2 from blah
    

    The spliton would be “ID,fooid,BarName,foobarid”. As it ran over the return set, it will map the properties that it can find in each object.

    I hope that this helps, and that your return set is not too big to return flat.

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

Sidebar

Related Questions

I have recently started a new job and noticed that all the SQL tables
I have recently started working on a very large C++ project that, after completing
I have recently started to look at sql reporting services. I have data stored
I have recently started using coffeescript with Rails and I am finding that sometimes
I have recently started a personal project that uses ASP.NET MVC (RC1 at the
I have recently started reading up on Grails and would like to use SQL
I have recently started using SQLALCHEMY to query a my-sql database. I want to
I have recently started work on an application that is already deployed to production.
I have recently started to explore the way that the C++ runtime library is
I have recently started working on a legacy application that has most of its

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.