I have the following query (part of it)
dataSourceDPL = dataSourceFE.addDataSource(tableNum(DirPartyLocation), "DirPartyLocation"); dataSourceDPL.addLink(fieldNum(FiscalEstablishment_BR, DirPartyLocation), fieldNum(DirPartyLocation, RecId)); dataSourceDPL.fetchMode(QueryFetchMode::One2One); dataSourceDPL.joinMode(JoinMode::InnerJoin); dataSourceDPT = dataSourceDPL.addDataSource(tableNum(DirPartyTable), "DirPartyTable"); dataSourceDPT.addLink(fieldNum(DirPartyLocation, Party), fieldNum(DirPartyTable, RecId)); dataSourceDPT.fetchMode(QueryFetchMode::One2Many); dataSourceDPT.joinMode(JoinMode::InnerJoin); dataSourceCI = dataSourceDPT.addDataSource(tableNum(CompanyInfo), "CompanyInfo"); dataSourceCI.addLink(fieldNum(DirPartyTable, RecId), fieldNum(CompanyInfo, RecId)); dataSourceCI.fetchMode(QueryFetchMode::One2One); dataSourceCI.joinMode(JoinMode::InnerJoin);
Example:
Today I get
Record 1 - DataA DataB DataC A1 ID1 IDRelated1 RelatedData1 RelatedData1_2
Record 2 - DataX DataY DataZ B2 ID2 IDRelated1
And so on...
When I read the result in C# I get the relations but no record in each row. Is there a way to return the associated tables for each column even though they might be repeated in any previous row?
Thanks.
*This post is locked for comments
Solved.
1 - I created a projection to select only the fields I wanted from each dataset:
dataSourceDPL.fields().dynamic(NoYes::No); dataSourceDPL.fields().clearFieldList(); dataSourceDPL.fields().addField(fieldNum(DirPartyLocation, RecId)); dataSourceDPL.fields().addField(fieldNum(DirPartyLocation, Party));
2 - Then at C# I just set the property ReturnFlatDataSet to true.
That was it. :)
I've tried using ReturnFlatDataset but it generated a quite large xml file.
If possible I'd like to solve this on Dynamics end.
Thanks.
Using QueryBuilder.
I call a QueryService from C# and then the AifQueryBuilder custom class is executed returning the results.
How are you "getting" the data?
Mohamed Amine Mahmoudi
100
Super User 2025 Season 1
Community Member
48
Zain Mehmood
6
Moderator