Wednesday, February 1, 2012

How to execute the method on IL in AX

With the release of Microsoft Dynamics AX 2012, a huge focus has been around the move for X++ code to be compiled to IL

There are certain areas of AX that always compile down to IL / MSIL / CIL. All of those are in reference to the .Net Framework execution. This means, that the same C# code that actually executes, is compiled down to IL. The same now, takes place for some areas of X++. There are huge benefits in code execution when this is the case, and why this is such an important topic to understand from a performance point of view.

For more reading visit this link

Below code will execute the code in IL explicitly


/// <summary>
///    Initializes the <c>PurchTable</c> record from a <c>VendTable</c> record.
/// </summary>
/// <param name="_vendTable">
///    The vendor record from which to initialize; optional.
/// </param>
server public void  initFromVendTable(VendTable _vendTable = this.vendTable_OrderAccount())
{
    container               purchTableContainer;
    XppILExecutePermission  xppILExecutePermission;

    // Transition to IL to update the sales quantity
    xppILExecutePermission = new XppILExecutePermission();
    xppILExecutePermission.assert();

    purchTableContainer = runTableMethodIL(
                              tableStr(PurchTable),
                              tableStaticMethodStr(PurchTable, initFromVendTableIL),
                              [buf2Con(this, true), buf2Con(_vendTable, true)]);

    CodeAccessPermission::revertAssert();
    this.con2buf(purchTableContainer);
}


private static server container initFromVendTableIL(container _inputContract)
{
............
}

No comments:

Post a Comment