-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Even easier: make them expressions, so they can be used directly by the row factory. Something like this:
StoredProcedure.Create("usp_GetTree")
.WithResults<Tree, Branch>()
.AsHierarchical<Tree>(tree => tree.Id, branch => branch.OwnerId);This will clearly require overloads on the actual stored procedure classes, as every hierarchical relationship could need to be defined. At the very least, every type argument would require a getter for its Id (except the type that has no children, but which one is that going to be?), and for its parent Id. It might be better to add a new method that can be used to define the relationship between 2 of the result sets independently, so you could do this:
StoredProcedure.Create("usp_GetTree")
.WithResults<Tree, Branch, Root, Leaf>()
.WithHierarchicalMapping<Tree, Branch>(tree => tree.Id, branch => branch.OwnerId)
.WithHierarchicalMapping<Tree, Root>(tree => tree.Id, root => root.TreeId)
.WithHierarchicalMapping<Branch, Leaf>(branch => branch.Id, leaf => leaf.Branch)
.AsHierarchical<Tree>();