Click here to Skip to main content
15,743,179 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tow xelement

XML
<attribute name="VSProductId">
  <value id="1022693402">1022693402</value>
  <value id="1022616704">1022616704</value>
  <value id="1013246990">1013246990</value>
  <value id="1013017642">1013017642</value>
</attribute>

<attribute different="true" name="Manufacturer">
  <value id="1022693402">OKI Data</value>
  <value id="1013246990">Panasonic</value>
  <value id="1013017642">Printek, Inc</value>
</attribute>


I want to write outer join query in linq which gives the result like

XML
<attribute different="true" name="Manufacturer">
  <value id="1022693402">OKI Data</value>
  <value id="1022616704"></value>
  <value id="1013246990">Panasonic</value>
  <value id="1013017642">Printek, Inc</value>
</attribute>


Please give me a outer join query in linq.
Posted
Updated 9-Oct-14 0:37am
v2
Comments
ZurdoDev 9-Oct-14 8:05am    
Where are you stuck?

RyanDev is right. You have to try to do something!

I'd suggest to start here:
Advanced Query Techniques (LINQ to XML)[^]
LINQ to XML : Join Xml Data[^]
 
Share this answer
 
v2
Comments
[no name] 9-Oct-14 14:41pm    
My 5. Half of this you have to Transfer to Wes :)
Maciej Los 9-Oct-14 14:47pm    
Thank you, Bruno ;)
I saw so many Wes Aday's comments... In this case - RyanDev is right - of course ;)
[no name] 9-Oct-14 14:52pm    
Lol my glasses seems to be same bad :)
Maciej Los 9-Oct-14 14:57pm    
Sometimes it happens ;)
I found query which gives the above required result the query is like this

var ElementQuery = (from VSProd in VSProductIds.Descendants("value")
join EProd in Element.Descendants("value")
on (string)VSProd.Attribute("id") equals (string)EProd.Attribute("id") into EVSProd
from EP in EVSProd.DefaultIfEmpty()
select new XElement(EP==null ? new XElement("value",
new XAttribute("id", (string)VSProd.Attribute("id")),
string.Empty) : EP)
);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900