Cerating XElement string based on condition uing C# + LINQ! Help.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
I am trying to write XML files based on some conditions - wondering what is th ebest possible approach .
Say below is my code sudo snippet and based on certain condition , I need to travers class object and output details. Not sure whts the best way to achive my results? Any help , pointers would be great help
public void WriteTransaction(Dictionary<string, List<DDTradeOutput>> inputList)<br/>
{<br/>
// String is key and DDTradeOutput is my trade object which would have basic trade details.<br/>
// Key , Value <br/>
// D1 , {{T1,dt1,dt2,etc..},{T2,dt1,dt2,etc..},{T3,dt1,dt2,etc...}}<br/>
// D2, {{T1,dt1,dt2,etc..},{T3,dt1,dt2,tct..} }<br/>
// D3 , {T1,dt1,dt2,etc..}<br/>
// Now usiing LINQ I am trying to print to XML Output something like below , Wondering what is the best
<br/>
<br/>
<Root><br/>
<deals><br/>
<deal><br/>
<dealid> D1 </dealid><br/>
<Trade> T1</Trade>
<br/>
<Details> dt1 </Details><br/>
<Details> dt2 </Details><br/>
<Trade> T2</Trade>
<br/>
<Details> dt1 </Details><br/>
<Details> dt2 </Details>
<br/>
</deal><br/>
<deal><br/>
<dealid> D2 </dealid><br/>
<Trade> T1</Trade>
<br/>
<Details> dt1 </Details><br/>
<Details> dt2 </Details><br/>
<Trade> T2</Trade>
<br/>
<Details> dt1 </Details><br/>
<Details> dt2 </Details>
<br/>
</deal><br/>
<br/>
</deals> <br/>
<Root><br/>
}
Please not for each unique Deal - Trade and details are repeating - One- Many mapping<br/>
<br/>
<br/>

View the full article
 
Back
Top