I have two classes:
class Foo{
public int FooId { get; set; }
...
public Bar Bar { get; set }
}
class Bar{
public int BarId { get; set; }
public int FooId { get; set }
...
}
when i then run the query like this:
sqlConnection.Query<Foo, Bar, Foo>(
"SELECT * FROM Foo JOIN Bar ON Foo.FooId = Bar.FooId",
(foo, bar) => {
foo.Bar = bar;
return foo;
},
splitOn: "FooId");
the result would then be that all properties on both Foo and Bar will map up Except for Bar.BarId. After checking the column name and type in the database against my Bar class I still couldn't find any differences.
One strange thing I stumbled upon was that if I wrote:
"SELECT *, BarId AS BarId FROM Foo JOIN Bar ON Foo.FooId = Bar.FooId"
Bar.BarId actually mapped as expected, have I misunderstood how to use Dapper or is this a bug?