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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:27:03+00:00 2026-06-16T02:27:03+00:00

Say I have these 2 tables/domains [TableName(TableA)] [PrimaryKey(TableAId)] public class TableA { public int

  • 0

Say I have these 2 tables/domains

[TableName("TableA")]
    [PrimaryKey("TableAId")]
    public class TableA
    {
        public int TableAId { get; set; }
        public string City { get; set; }

        public TableB TableB { get; set; }

        public TableA()
        {
            TableB = new TableB();
        }

    }

    [TableName("TableB")]
    [PrimaryKey("TableBId")]
    public class TableB
    {
        public int TableBId { get; set; }
        public string Name { get; set; }
    }


var sql = @" Select TableA.*, TableB.*
FROM         TableA INNER JOIN
                      TableB ON TableA.TableBId = TableB.TableBID";

// peta poco
var result = db.Query<TableA, TableB>(sql);

When I do this the TableA.TableB gets filled and TableA id gets filled but City is null. I have to specify each column for it to bind. Is there away to just use the star instead of specifying each column?

  • 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-16T02:27:04+00:00Added an answer on June 16, 2026 at 2:27 am

    What you have there should work however, what I think might be happening is due to these conditions happening:

    1. You have a column TableBId on TableA
    2. You don’t have a TableBId property on the class TableA
    3. When you run the query manually, City is coming after TableBId on the TableA.* part

    The mapping works by running through the columns in order and the processing works by:

    1. If the column in on the first class in your generic parameter list it will get mapped and move on to the next column (still using the first class for mapping)
    2. If the column is not on the first class, then it will consider the first class finished and move to the second class and so on….
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have these two classes: public class Base { public static int
Let's say I have these class hierarchy : public abstract class Parent { }
say if I have 10 tables. These tables are joined together on different conditions.
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
Say I have these tables: people(id, name), cars(person_id, car) and this query: SELECT c.car
Let's say that I have these tables on my db: items categories weapons shields
Let's say I have these tables, with these fields: companies : company_id | name
Let's say we have these tables: CREATE TABLE A ( id SERIAL NOT NULL
Let's say I have these two tables: ParentDataItem ParentDataItemID ...some other fields... ChildDataItem ChildDataItemID
Alright, let's say I have these two tables: items with columns id, stuff item_properties

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.