06.03.2008, 06:14 | #1 |
Участник
|
C# and AX Development: Complex Queries in AX
Источник: http://olondono.blogspot.com/2008/03/queries-in-ax.html
============== Overview from Axaptapedia - Expressions in query ranges For build complex queries, we can use any field, but normally, DataAreaId is used. X++: query = new Query(); dsInventTable = query.addDataSource(tableNum(InventTable)); // Add our range queryBuildRange = dsInventTable.addRange(fieldNum(InventTable, DataAreaId)); X++: queryBuildRange.value(strFmt('((ItemType == %1) || (ItemId == "%2"))', any2int(ItemType::Service), queryValue("B-R14"))); X++: queryBuildRange.value(strFmt('(ModifiedDate > %1)', Date2StrXpp(01012000))); X++: query = new Query(); dsInventTable = query.addDataSource(tableNum(InventTable), tableStr(InventTable)); dsInventItemBarCode = dsInventTable.addDataSource(tableNum(InventItemBarCode), tableStr(InventItemBarCode)); dsInventItemBarCode.relations(true); dsInventItemBarCode.joinMode(JoinMode::ExistsJoin); // Add our two ranges queryBuildRange1 = dsInventTable.addRange(fieldNum(InventTable, DataAreaId)); queryBuildRange2 = dsInventItemBarCode.addRange(fieldNum(InventItemBarCode, DataAreaId)); queryBuildRange2.value(strFmt('(ModifiedDate > InventTable.ModifiedDate)')); X++: queryBuildRange2.value(strFmt('((%1.%2 == %3) || ((%1.%2 == %4) && (%1.%5 == %6)))', query.dataSourceTable(tableNum(InventTable)).name(), // InventTable %1 fieldStr(InventTable, ItemType), // ItemType %2 any2int(ItemType::Service), // %3 any2int(ItemType::Item), // %4 fieldStr(InventTable, ItemId), // ItemId %5 fieldStr(InventItemBarCode, ItemId))); // %6 From http://axapta.blogcu.com/387572/ X++: queryBuildRange.value(strFmt('((Dimension == %1) || (Dimension2_ == "%2"))', "some dim1 value", "some dim2 value")); X++: queryBuildRange = dsLedgerTrans.addRange(fieldId2Ext(fieldNum(LedgerTrans, Dimension),1));
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|