How to create object hierarchy with dapper.net?

dapper

Question

I have a table defination as below:

enter code here

CREATE TABLE Milestone
( 
    MilestoneID Int,
    MilestoneName Nvarchar(256),
    ParentMilestoneID Int
)

Class defination as below:

enter code here

public class Milestone
{
    public int MilestoneID {get;set;}
    public string MilestoneName {get;set:}
    public Milestone milestone {get;set;}
}

How to mapping sql query to parent-child hierarchy objects?

Any suggestion or idea is welcome.

Popular Answer

This is not exactly a hierarchy, but is better a parent-child relationship, I suppose you can look in the example page in the section called Multi Mapping.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why