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

  • Home
  • SEARCH
  • 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 6331193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:00:54+00:00 2026-05-24T18:00:54+00:00

I’m trying to decide the best approach for a new project I’m about to

  • 0

I’m trying to decide the best approach for a new project I’m about to start on, when it comes to my model design (and I’m using Dapper.net).

I like the idea of having my models with objects rather than Foreign Key properties, i.e.

public Post LastPost { get; set; }

vs

public int LastPostId { get; set; }

However, if I implement this sort of nice clean approach, I have to multi-map to all objects (which leads onto potential circular referencing of objects within objects, (or have to stop multi-mapping at a certain point and therefore end up with NULL objects at some point down the object tree). Also, if I do multi-map to an extent, then Im perhaps causing unnecessary work, performing joins etc when they’re not always going to be needed.

Or, if I decide to use multi-mapping to populate my objects within objects on a ‘as needed’ basis (in some of my repos methods perform multi mapping because its needed, and in other repos methods, don’t bother populating the objects), then it feels kind of dirty in that I can’t always be sure if an object (within an object) is null or not.

I’ve used NHibernate (or at least some of its more basic functionality) in the past and not had the dilemma as I always had objects within my models and if/when they were needed, I could rely on lazy loading to go get them – However, not having that lazy loading with Dapper.net I’m really unsure of the best approach to go with?

  • 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-24T18:00:56+00:00Added an answer on May 24, 2026 at 6:00 pm

    Why not have the best of both worlds?

    bool _lastPostLoaded;
    private Post _lastPost; 
    public Post LastPost 
    { 
       get 
       {
          if(!_lastPostLoaded)
          {
             _lastPost = cnn.Query<Post>("select * from Posts where Id = @lastPostId", 
                  new {lastPostId});
             _lastPostLoaded = true;
          }
          return _lastPost;
       } 
       set 
       {
          _lastPost = value;
          _lastPostLoaded = true;
       }
    }
    

    This allows you to eager load when needed with multi mapping and lazy load, when you are lazy;

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place
Specifically, suppose I start with the string string =hello \'i am \' me And

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.