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

Create query in X++

$
0
0

Hi guys,

I am trying to build a query in X++ but i can't seem to do it right.

Example:

Table 1

Table 2 => Has a relation with Table 1

Table 3 => Has a relation with Table 1

My code:

Query query = new Query();

QueryBuildDatasource qbds1, qbds2, qbds3;

qbds1 = query.addDatasource(tableNum(Table1));

qbds2 = qbds1.addDatasource(tableNum(Table2));

qbds2.relation(true);

qbds3 = qbds1.addDatasource(tableNum(Table3));

qbds3.relations(true);

Now my problem:

Adding Table1 => Ok, in debugger i can see query object as "Query object 2c70e208: SELECT * FROM Table1(Table1_1)"

Adding Table2 => Ok, in debugger i can see query object as "Query object 2c70e208: SELECT * FROM Table1(Table1_1) JOIN * FROM Table2(Table2_1) ON Table1.Id = Table2.Id"

Adding Table3 => NOK, the query object looks to be broken and in the debugger it gets the following value "Query object 2c70e208"

When i write the query in a select statement, in SQL or build it in a AOT query there is no problem and i get the results correctly.

Does anyone have an idea what's wrong?


Viewing all articles
Browse latest Browse all 175888

Latest Images

Trending Articles



Latest Images

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