abe545 / CodeOnlyStoredProcedures

A library for easily calling Stored Procedures in .NET using only code (no xml or gui).
MIT License
4 stars 3 forks source link

Add hierarchical model support #3

Closed abe545 closed 9 years ago

abe545 commented 9 years ago

One of the most common use cases for SPs that return multiple result sets is that they have a hierarchical relationship. It would be nice if this could be automatically detected, and the child items assigned to a property. For instance, if you have a SP that returns 2 result sets:

Family: LastName, Id
Person: FirstName, Id, FamilyId

You should be able to call a stored proc: new StoredProcedure<Family>()...

and define the models:

public class Family
{
    public int Id { get; set; }
    public string LastName { get; set; }
    public IEnumerable<Person> Members { get; set; }
}

public class Person
{
    public int Id { get; set; }
    public int FamilyId { get; set; }
    public string FirstName { get; set; }
}

It should follow the same conventions as described at this MSDN blog.