I have a result set that might look like this:
ID (no column name) anotherID
---- ---------------- ----------
1 super 3
1 super 4
3 duper 6
4 really 7
4 really 8
I have 2 issues:
First: How do I use dapper with a column with no name?
Second: I want to have a parent child relationship such that I get 3 objects each with a list of anotherID’s for example:
public class MyObject
{
public int ID
public string Name
public int[] Children
}
Well, un-named columns are not supported by dapper. I never really saw a reason for them.
I guess we could build support for:
The trouble is that it introduces a very fragile method of querying which I strongly dislike, passing a directive to
Queryis just as clunky.However, if you are happy to change the way you grab the results you could work around this.
Then use the technique here to multi map: Multi-Mapper to create object hierarchy