I have below xml.
<?xml version="1.0" encoding="utf-8" ?>
<MESSAGE ID="PND">
<STORE ID="6697">
<HEADER ID ="1"
LOADCLOSEDDATETIME="20130312121212"
DELIVERYDATE="20130312"
TRAILERID=""
TRIPROUTEID=""
DEPOTCODE=""/>
<RECORD TPNB="123456666"
NOOFCASES=""
OUTERCASELENGTH="1"
OUTERCASEWIDTH="2"
OUTERCASEHEIGHT="3"
UNITSPERCASE=""
USEBYDATE="20130312121212"
MU="">
</RECORD >
<RECORD TPNB="123456666"
NOOFCASES=""
OUTERCASELENGTH ="1"
OUTERCASEWIDTH="2"
OUTERCASEHEIGHT="3"
UNITSPERCASE=""
USEBYDATE="20130312121212"
MU="">
</RECORD>
</STORE>
<STORE ID="6647">
<HEADER ID ="1"
LOADCLOSEDDATETIME="20130312121212"
DELIVERYDATE="20130312"
TRAILERID=""
TRIPROUTEID=""
DEPOTCODE=""/>
<RECORD TPNB="123456666"
NOOFCASES=""
OUTERCASELENGTH ="1"
OUTERCASEWIDTH="2"
OUTERCASEHEIGHT="3"
UNITSPERCASE=""
USEBYDATE="20130312121212"
MU="">
</RECORD>
</STORE>
<TRAILER ID="9" RECORDCOUNT=" 3" />
</MESSAGE>
I want to populate an entity with this xml where all my records belonging to a particular storeid
should be grouped together into a list.
var _preNotifiedProduct =
from nlist in xDocument.Descendants("RECORD")
group nlist by nlist.Anestors("STORE").Attributes().First().Value
into cust
select new {key=cust.Key,value = ??};
Here key is my store id, and the value should be list of type (XElement) RECORD which belongs to that store id.
If I assign value=cust
this will show me all nonpublic member elements which are in the Record xelement list.
How do I get it into a xelement list?