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?
What you have there should work however, what I think might be happening is due to these conditions happening:
TableBIdonTableATableBIdproperty on the classTableATableBIdon theTableA.*partThe mapping works by running through the columns in order and the processing works by: