Вот это у меня работает (Ax 3.0 SP 2, MS SQL Server 2000):
Код:
static void Job40(Args _args)
{
Query q = new Query();
QueryRun qr;
QueryBuildDataSource qbDS1, qbDS2;
InventSum inventSum;
InventTable inventTable;
InventDim inventDim;
;
qbDS1 = q.addDataSource(tableNum(InventSum));
qbDS2 = qbDS1.addDataSource(tableNum(InventTable));
qbDS2.joinMode(JoinMode::OuterJoin);
qbDS2.fetchMode(QueryFetchMode::One2One);
qbDS2.relations(true);
qbDS2 = qbDS1.addDataSource(tableNum(InventDim));
qbDS2.joinMode(JoinMode::OuterJoin);
qbDS2.fetchMode(QueryFetchMode::One2One);
qbDS2.relations(true);
qbDS2.addRange(fieldnum(InventDim, DataAreaId)).value(strfmt(
"((%1.DataAreaId == %2.DataAreaId) || (%1.DataAreaId != %2.DataAreaId))",
qbDS2.name(),
q.dataSourceTable(tablenum(InventTable)).name()
));
info(qbDS1.toString());
qr = new QueryRun(q);
qr.next();
inventSum = qr.get(tablenum(InventSum));
inventTable = qr.get(tablenum(InventTable));
inventDim = qr.get(tablenum(InventDim));
info(strfmt("%1 %2 %3", inventSum.ItemId, inventTable.ItemName, inventDim.inventDimId));
}