我正在使用Subsonic ORM。如何执行此查询? (在使用两个Area表时遇到麻烦。)
SELECT Area.AreaDescription, Area_1.AreaDescription AS Expr1, DocumentHeader.XNumber, DocumentDetail.Qty
FROM
DocumentDetail
INNER JOIN
DocumentHeader ON DocumentDetail.DocumentHeaderId = DocumentHeader.DocumentHeaderId
INNER JOIN
Area AS Area_1 ON DocumentDetail.AreaId = Area_1.AreaId
INNER JOIN
Area ON DocumentHeader.AreaId = Area.AreaId
我遇到的问题是别名“ AS Area_1”,以及在该别名表中选择实际字段。到目前为止,这是我的代码...
SqlQuery qry = new Select(
"DocumentHeader.XNumber",
"DocumentDetail.Qty",
"Area.AreaDescription",
"Area_1.AreaDescription""
)
.From(DocumentHeader.Schema)
.InnerJoin(DocumentDetail.DocumentHeaderIdColumn, DocumentHeader.DocumentHeaderIdColumn)
.InnerJoin(Area.AreaIdColumn, DocumentHeader.AreaIdColumn)
.InnerJoin("Area AS Area_1", "AreaId", "DocumentDetail", "AreaId");
由于带有别名的InnerJoin,我得到一个对象引用未设置错误。