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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:24:34+00:00 2026-06-18T12:24:34+00:00

Im trying to make a generic method for Dapper.Query. Now i have run into

  • 0

Im trying to make a generic method for Dapper.Query. Now i have run into trouble.
Here is my example

   public IEnumerable<T1> Lazy<T1, T2>(T2 table) where T1 : EntityBase
    {

        using (IDbConnection cn = GetCn())
        {
            cn.Open();

            return cn.Query<T1, T2, T1>("query", (t1, t2) => { t1.???
        }
    }

As you se below, i need to now the properties in t1 to load it with t2.
Is this even possible?

This example is not completed, of course the “query” string will be replaced, this is just for demo.

  • 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-18T12:24:36+00:00Added an answer on June 18, 2026 at 12:24 pm

    Dapper does not include lazy loading, and provides exactly zero support to help achieve lazy loading, because that isn’t what it is trying to do – it is a utility, not a framework. However, your example suggests you are talking about horizontally partitioned data, for example, say we had:

    select foo.*, bar.*
    from foo inner join bar on bar.ParentId = foo.Id
    where foo.Category = @category
    

    and suppose for simplicity that both [foo] and [bar] have an Id column (which it handles automatically, although there are ways of specifying the partitioning rules manually). Then this would become:

    return cn.Query<Foo, Bar, Foo>(query, args, (foo, bar) => {
        foo.Bar = bar;
        return foo;
    });
    

    or something similar. The point is: it materializes the Foo and the Bar separately (based on the partition), then lets you worry about how to combine them.

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

Sidebar

Related Questions

I have an extension method I'm trying to make generic, for message passing. public
I'm trying to make a generic method from this method: public static SelectList LanguagesToSelectList()
I have a page that I am trying to make a generic style of
I'm trying to make this code generic: public final Object unwrap(Class arg0) { throw
I am trying to make a Generic FindControl method and I get the following
I'm trying to make a generic class to save log Here we use entity
I have a very simple generic constructor method: public T Instance<T, TT>(TT parms) where
I am trying to make a generic Duplicate linq extension method. But I cannot
I'm having trouble with suds . I'm trying to make a generic system to
I have a generic method: public bool DoSomething<T>(T item) where T: IBase { return

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.