Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

Cannot chain call from Query object in X++

$
0
0

Hi,

There is something particulary odd in AX2012 R2 CU9 (not tested in more recent versions) when we use Query object.

Consider the following example code:

new Query(queryStr(InventTable)).datasourceTable(tableNum(InventTable)).clearRanges();
(I used queryStr(...) to initialize the query but it could have been made using a packed query container or whatever)

This throws an exception "QueryBuildDataSource object not initialized". In order to resolve the issue, I have to explicitely store the query object in a new variable, like this:

Query    query = new Query(queryStr(InventTable));
query.datasourceTable(tableNum(InventTable)).clearRanges();

This way, the querybuilddatasource object is properly returned. The weird thing is, the first snippet of code works well in CIL context. It does not work in traditional X++ interpreter mode.

Actually, we found this while using the SysOperation framework,
we had some code pattern in our service class that looked like:

// Pseudo-code
public void process(_contract)
{
    _contract.getQuery().datasourceTable(tablenum(....
}

It was running pretty well in CIL until we wanted to test it in X++ by disabling CIL execution...

I can't really explain this difference in behavior, so if somebody from MS who knows kernel code can give us an explanation, he/she is welcome :)

Otherwise, maybe it can help some of us.

See you!


Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>