To Process the Result of the Execution of the BQL Statement
Select() returns the PXResultset<T0> object. The type parameter (T0) is set to the first table selected by the business query language (BQL) statement, and PXResultset<T0> is a collection of PXResult<T0> objects. You can iterate through the result set in a foreach loop and obtain either data access class (DAC) instances or PXResult<> instances. A PXResult<> instance represents a whole result set record and can be cast to any of the DAC types joined in the BQL statement.
To Get the Objects of the Primary DAC
In the foreach
loop, cast each PXResult<T0>
object in the collection to an object of the main DAC. The
PXResult<T0> object is implicitly converted to the
T0 class. In the following sample code, records are selected
from the Document
table.
// Result set records are implicitly cast to the Document DAC.
foreach(Document doc in SelectFrom<Document>.View.Select(this))
{
...
}
To Get the Objects of Joined DACs
- In the
foreach
loop, cast each PXResult<T0> object in the collection to the needed PXResult<T0, T1, T2, ...> object, where T0, T1, T2, and other type parameters are joined DACs from the BQL statement. The PXResult<T0, T1, T2, ...> type must be specialized with the DACs of all joined tables. - Cast each PXResult<T0, T1, T2, ...> item to any of the listed types to get the object of this type.
// The static Select() method is called to execute a BQL command.
PXResultset<OrderLine> result =
SelectFrom<OrderLine>.InnerJoin<SalesOrder>.
On<SalesOrder.orderNbr.IsEqual<OrderLine.orderNbr>>.View.Select(this);
// Iterating over the result set:
// PXResult should be specialized with the DACs of all joined tables
// to be able to cast to these DACs.
foreach(PXResult<OrderLine, SalesOrder> record in result)
{
// Casting a result set record to the OrderLine DAC:
OrderLine detail = (OrderLine)record;
// Casting a result set record to the SalesOrder DAC:
SalesOrder order = (SalesOrder)record;
...
}
(var line, var poLine, var _, var lotSerClass) =
(PXResult<POReceiptLine, POLine, InventoryItem, INLotSerClass>)
SelectFrom<POReceiptLine>
.LeftJoin<POLine>.On<POReceiptLine.FK.OrderLine>
.LeftJoin<InventoryItem>.On<POReceiptLine.FK.InventoryItem>
.LeftJoin<INLotSerClass>.On<InventoryItem.FK.LotSerClass>
.Where<POReceiptLine.receiptType.IsEqual<@P.AsString>
.And<POReceiptLine.receiptNbr.IsEqual<@P.AsString>>
.And<POReceiptLine.lineNbr.IsEqual<@P.AsInt>>>
.View.Select(Base, split.ReceiptType, split.ReceiptNbr, split.LineNbr);
var row = (PXResult<POReceiptLine, POLine, InventoryItem, INLotSerClass>)
SelectFrom<POReceiptLine>
.LeftJoin<POLine>.On<POReceiptLine.FK.OrderLine>
.LeftJoin<InventoryItem>.On<POReceiptLine.FK.InventoryItem>
.LeftJoin<INLotSerClass>.On<InventoryItem.FK.LotSerClass>
.Where<POReceiptLine.receiptType.IsEqual<@P.AsString>
.And<POReceiptLine.receiptNbr.IsEqual<@P.AsString>>
.And<POReceiptLine.lineNbr.IsEqual<@P.AsInt>>>
.View.Select(Base, split.ReceiptType, split.ReceiptNbr, split.LineNbr);
POReceiptLine line = row;
POLine poLine = row;
INLotSerClass lotSerClass = row;