Friday, 3 November 2017

SQL In<> Operator in BQL

Hi There,

Today want to show you example of amazing and very new BQL Operator - In<>.
This operator was added just recently with Acumatica version 2017R2, so now you can pass there an array of values and Acumatica core will convert it to SQL IN ( ... ) statement.

Here is a code example:
Object[] values = new String[] { "AC""IN" };
InventoryItem item = PXSelect<InventoryItem,
       Where<InventoryItem.itemStatus,
In<Required<InventoryItem.itemStatus>>>>.Select(Base, values);
Console.WriteLine(item.Descr);

This will be converted to following SQL
Select * from InventoryItem InventoryItem
Where InventoryItem.Status In ('AC', 'IN')
Order by InventoryItem.InventoryCD

Please note that In<> operator is available only with Required<> parameter and you need to pass array of possible values manually to Select(...) method parameters.

Have a nice development!

No comments: