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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:21:54+00:00 2026-06-03T11:21:54+00:00

I want to execute a single Query (or Stored Proc with multiple resultsets). I

  • 0

I want to execute a single Query (or Stored Proc with multiple resultsets). I know how to do Multi-mapping using Dapper, but I can’t sort how to map the two collections onto the same parent. Basically, given this Object definition…

class ParentObject
{
    string Name { get; set; }
    ICollection<ChildObjectOne> ChildSetOne {get;set;}
    ICollection<ChildObjectTwo> ChildSetTwo { get; set; }
}

class ChildObjectOne
{
    string Name { get; set; }
}

class ChildObjectTwo
{
    int id { get; set; }
    string LocationName { get; set; }
}

I want to be able to run a Dapper query that somehow yields:

IQueryable<ParentObject> result = cnn.Query(
          // Some really awesome dapper syntax goes 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-06-03T11:22:00+00:00Added an answer on June 3, 2026 at 11:22 am

    Not sure if you DON’T want to use MultiMapping but here’s how it would work for your case. As far as I know and read on SO, is not not possible to map a deep nested object graph with a simple Query.

     static void Main(string[] args)
            {
                var sqlParent = "SELECT parentId as Id FROM ParentTable WHERE parentId=1;";
                var sqlChildOneSet = "SELECT Name FROM ChildOneTable;"; // Add an appropriate WHERE
                var sqlChildTwoSet = "SELECT Id, LocationName FROM ChildTwoTable;"; // Add an appropriate WHERE
    
                var conn = GetConnection() // whatever you're getting connections with
                using (conn)
                {
                    conn.Open();
                    using (var multi = conn.QueryMultiple(sqlParent + sqlChildOneSet + sqlChildTwoSet))
                    {
                        var parent = multi.Read<ParentObject>().First();
                        parent.ChildSetOne = multi.Read<ChildOne>().ToList();
                        parent.ChildSetTwo = multi.Read<ChildTwo>().ToList();
                    }
                }
            }
    

    Similar questions for nested objects and dapper :

    https://stackoverflow.com/search?q=nested+objects+%2B+dapper

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

Sidebar

Related Questions

I have a SQL query where I want to insert multiple rows in single
I'm using HRD because I want make changes to multiple entities within a single
I want to execute a script every 30mins, but i want to use it
I want to execute a batch file from a java program. I am using
i want to execute the query in master database it self IF OBJECT_ID(N'DB1.dbo.T_table1', N'U')
I want to execute a query like this var result = from entry in
I have 4 mysql tables and have a single query with JOIN on multiple
I want to execute following query: from Item i where i.categoryItems.catalogId = :catId That
i want use single quotations inside a transact sql statement, then execute that statement.
I want to execute a MYSQL query: INSERT INTO taskattempts (taskID) VALUES (_); which

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.