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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:53:38+00:00 2026-05-30T14:53:38+00:00

I have a database with id columns like BookId, AuthorId, etc. My code files,

  • 0

I have a database with id columns like BookId, AuthorId, etc. My code files, however, just have an Id property. I’m attempting to convert parts of the program that use NHibernate with Dapper, so I’m trying to eliminate the need for both an Id and a BookId property on . NHibernate has a built in identity map that maps BookId to the Id property of Book objects and similarly AuthorId to the Id property on Author objects.

Is there a way to do this Dapper, outside of giving an alias to the column, in the sql query?

public class Book {
  public int Id { get; set; }
  public string Name { get; set; }
}

public class Author {
  public int Id { get; set; }
  public string Name { get; set; }
}

A sample query that I’m using looks like:

select * from Books b inner join Author a on a.AuthorId = b.AuthorId

If Dapper doesn’t support this easily, any thoughts on what other options I have?

  • 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-30T14:53:40+00:00Added an answer on May 30, 2026 at 2:53 pm

    By design, dapper does not have a mapping layer. One step down that road, and before we know what has happened all of a sudden we’ll be drowning in configuration files. So: two options:

    • add an alias in the SQL
    • add a shim in the C#

    so either (sql):

    select BookId as [Id], Name from Books
    

    or (C#):

    private int BookId { get { return Id; } set { Id = value; } } // just for dapper
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that has four columns like this level_1, level_2, level_3, level_4
I have a database with columns looking like: session | order | atype |
In legacy database tables we have numbered columns like C1, C2, C3, C100 or
I have a table in a SQL Server 7.0 database with columns like: Column_1
I have a mysql database table called character with columns like name, strength, intelligence,
I have a users table in my mysql database with columns like id, age
One of my database table columns have name like 'name@from' how can i write
Let's say I have a database column 'grade' like this: |grade| | 1| |
I currently have a Postgres 8.4 database that contains a varchar(10000) column. I'd like
Suppose I have a database table with columns a, b, and c. I plan

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.