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 run the query as follows:
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 is that all properties for both Foo and Bar will be displayed with the exception of Bar.BarId. After checking the column name and entering the database in my Bar class, I still didn't find any differences.
One strange thing that I came across was that if I wrote:
"SELECT *, BarId AS BarId FROM Foo JOIN Bar ON Foo.FooId = Bar.FooId"
Bar.BarId actually displays as expected, I misunderstood how to use Dapper or is this a bug?
source
share