Источник:
http://kamalblogs.wordpress.com/2010...n-dynamics-ax/
==============
When you execute a select statement to retrieve a single record most of us right the query first. This is followed by a validation to ensure that the query has returned a record. we make it simpler If we right it the way mentioned below…
X++:
static void WhileSelectInsteadoFSelect(Args _args)
{
InventTable inventTable;
;
-----General way---------
//fetch the record first
select firstonly forupdate inventtable;
//add an additional validation
if (inventTable.recid)
{
inventTable.itemName = 'newname';
inventTable.update();
}
------Alternate--------------
//prevents the extra 'if' chek
while select firstonly forupdate inventTable
{
inventTable.itemName = 'newname';
inventTable.update();
}
//can also be used for simple readonly
while select firstonly inventTable
{
Info(inventTable.ItemId);
}
}
A few of you might already follow it but for the rest it could be a learning
Источник:
http://kamalblogs.wordpress.com/2010...n-dynamics-ax/