Trying to access AX 2012 QueryService through c# application and would like to get CustomerID and Customername fields only. Problem is, CustomerID is in CustTable and CustomerName is in DirPartyTable.
Any help to article or code samples would be appreciated.
- Reference to QueryDataSourceMetadata to put join in these tables and get data.
- What are the options and when to use Relations and JoinMode?
I searched in MSDN and it just lists the property names and methods and not much help in the form of code samples.
Its too late to answer and I think you already might have found some solutions. Anyway here is the link to my response on AX community:
https://community.dynamics.com/ax/f/33/p/212065/573674#573674
I found 2 ways to add the relations from c#. I have commented the first approach based on AOT table relation. In the code below QueryServiceReference is the service reference name in VS. You can remove it in all the lines if you have only QueryService reference but no MetaDataService reference. Here is the code :
According to my knowledge, you put in the two tables you want to query into your QueryDataSourceMetadata. The resulting dataset should contain both tables. (Example code for creating a QueryDataSourceMetadataObject is here: http://msdn.microsoft.com/EN-US/library/gg844682.aspx)
The property you need, for the tables to be joined, is ReturnFlatDataSet. (this may help: http://msdn.microsoft.com/EN-US/library/gg841671.aspx)
Hope i could help you or point you in the right direction!