Writing LINQ query from XML element [Resolved]

Posted by Self-Innovator under LINQ on 4/28/2016 | Points: 10 | Views : 210 | Status : [Member] | Replies : 1
Hi All,

I'm trying to write a LINQ query fro XML Document i'm getting an exception, i'mnew to LINQ kindly suggest

var storeReportClient = new UATStoreReportServiceReference.oraclemdb1SoapClient("oraclemdb1Soap12");
var result = storeReportClient.GetLogisticsAsync(StoreId.ToString()).Result;
var logisticsElement = XElement.Parse(result).Elements("logistics");
LogisticsInfoViewModel logisticInfo = (from f in logisticsElement.Attributes("freight")
select new LogisticsInfoViewModel
{
//Frieght details
FreightRate = f.Attribute("freightrate").Value,
OffShoreDelivery = f.Attribute("offshoredelivery").Value,
StartCode = f.Attribute("stratcode").Value,
MultiDelivery = f.Attribute("multipledelivery").Value,
Palletized = f.Attribute("palletized").Value,
TotesShipped = f.Attribute("totesshipped").Value,
TotesReturned = f.Attribute("totesreturned").Value,
TotesLastDate = f.Attribute("toteslastdate").Value,
ContainersShipped = f.Attribute("containersshipped").Value,
ContainersReturned = f.Attribute("containersreturned").Value,
ContainersLastDate = f.Attribute("containerslastdate").Value,

//Route details
Routes = (from r in logisticsElement.Elements("routes").Elements()
select new LogisticsRoute
{
DayOfTheWeek = r.Attribute("dayofweek").Value,
GroupNo = r.Attribute("groupnbr").Value,
TruckRouteId = r.Attribute("truckrouteid").Value,
OrderPickRequest = r.Attribute("truckrouteid").Value,
TruckLoadSeq = r.Attribute("truckloadseq").Value,
TruckLoadSeq2 = r.Attribute("truckloadseq2").Value,
Shift = r.Attribute("shift").Value
}).ToList()
}
).FirstOrDefault();

return logisticInfo;


Errror:Error 8 Could not find an implementation of the query pattern for source type 'System.Collections.Generic.IEnumerable<System.Xml.Linq.XAttribute>'. 'Select' not found. Are you missing a reference or a using directive for 'System.Linq'? C:\SVN\MembersOnline\trunk\MOL2.0\Projects\Mol2.Data.Services\StoreReportsService.cs 53 62 Mol2.Data.Services

Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Professionaluser on: 4/28/2016 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
I wanted to highlight the part of error message which you got...

Errror:Error 8 Could not find an implementation of the query pattern for source type 'System.Collections.Generic.IEnumerable<System.Xml.Linq.XAttribute>'. 'Select' not found. Are you missing a reference or a using directive for 'System.Linq ' ? C:\SVN\MembersOnline\trunk\MOL2.0\Projects\Mol2.Data.Services\StoreReportsService.cs 53 62 Mol2.Data.Services

So did you refer System.Linq reference?

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response