Insight.Database supports mapping One to Many results if the SQL has multiple SELECT statements, one for Parent and the for the children. See: https://github.com/jonwagner/Insight.Database/wiki/Specifying-Result-Structures
CREATE PROC GetBeerAndPossibleGlasses AS
SELECT * FROM Beer
SELECT b.BeerID, g.* FROM Beer JOIN Glasses ON (...)
class Beer
{
public int ID;
public IList<Glass> Glasses;
}
var results = connection.Query("GetBeerAndPossibleGlasses", Parameters.Empty,
Query.Returns(Some<Beer>.Records)
.ThenChildren(Some<Glasses>.Records);
Can the one-to-many mapping be done using a single join query? I believe this is supported in Petapoco. (I am using Auto Interface implementation but I would like to know if there is any way at all to accomplish it.) e.g.
CREATE PROC GetBeerAndPossibleGlasses AS
SELECT b.*, g.* FROM Beer JOIN Glasses ON (...)
I have relatively complex query where I need to return parent and children as above. It works if I create multiple SELECT statments but my select statement look like below:
SELECT * FROM Beer WHERE <Complex WHERE clause>
SELECT b.BeerID, g.* FROM Beer JOIN Glasses ON (...) <Complex WHERE clause>
I am worried that the query is as efficient as a single join.