Can someone help me figure out how to sum the quantity value here in the EntityCollection in C#?
Thanks in advance.
string fetchXmlResult =
@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' >
<entity name='salesorder'>
<attribute name='productid'/>
<attribute name='ordernumber'/>
<attribute name='quantity'/>
</entity>
</fetch>";
XmlElement element1= xml.CreateElement(string.Empty, "Order", xml.DocumentElement.NamespaceURI);
EntityCollection xmlResult = _crmservice.RetrieveMultiple(new FetchExpression(fetchXmlResult()));
foreach (Entity e in xmlResult.Entities)
{
XmlElement ordernumber= xml.CreateElement("OrderNumber", xml.DocumentElement.NamespaceURI);
ordernumber.InnerText = e.Attributes["ordernumber"]).ToString();
element1.AppendChild(ordernumber);
XmlElement productid= xml.CreateElement("ProductId", xml.DocumentElement.NamespaceURI);
productid.InnerText = e.Attributes["productid"]).ToString();
element1.AppendChild(productid);
}
Open in new window