S
Sudip_inn
Guest
1) Why author used here SelectMany() instead of select ?
XDocument xmlDocTargetFile = XDocument.Load(ADM_File_Path);
//removing duplicate data
xmlDocTargetFile.Descendants("TickerBrokerDateFormatMap").GroupBy(row =>
new
{
StandardDate = row.Element("StandardDate").Value,
Broker_Id = row.Attribute("Broker_Id").Value,
BrokerTab_Id = row.Attribute("BrokerTab_Id").Value
})
//.Where(grp => grp.Count() > 1)
.SelectMany(m => m.Skip(1)).Remove();
xmlDocTargetFile.Save(ADM_File_Path);
Why author used here SelectMany() instead of Select() ?
please discuss with example to understand.
2)
can we use .Select() before where() ?
string strActualProvidedByCompany = dtColoInfo.AsEnumerable()
.Where(j => j.Field<string>("Section").ToUpper() == strSection.ToUpper()
&& j.Field<string>("LineItem").ToUpper() == strLineItem.ToUpper()
&& j.Field<string>("Period").ToUpper() == strPeriod.ToUpper())
.Select(a => a.Field<string>("ActualProvidedByCompany")).FirstOrDefault();
probably i tried to write Select() before where then i was getting error but the moment i place Select() after Where() then error gone. in sql we write select first and then filter. in LINQ can't we use select before WHERE() ?
tell me why i was getting error when i place select() before where() ?
please discuss my 2 question with example to better understand. thanks
Continue reading...
XDocument xmlDocTargetFile = XDocument.Load(ADM_File_Path);
//removing duplicate data
xmlDocTargetFile.Descendants("TickerBrokerDateFormatMap").GroupBy(row =>
new
{
StandardDate = row.Element("StandardDate").Value,
Broker_Id = row.Attribute("Broker_Id").Value,
BrokerTab_Id = row.Attribute("BrokerTab_Id").Value
})
//.Where(grp => grp.Count() > 1)
.SelectMany(m => m.Skip(1)).Remove();
xmlDocTargetFile.Save(ADM_File_Path);
Why author used here SelectMany() instead of Select() ?
please discuss with example to understand.
2)
can we use .Select() before where() ?
string strActualProvidedByCompany = dtColoInfo.AsEnumerable()
.Where(j => j.Field<string>("Section").ToUpper() == strSection.ToUpper()
&& j.Field<string>("LineItem").ToUpper() == strLineItem.ToUpper()
&& j.Field<string>("Period").ToUpper() == strPeriod.ToUpper())
.Select(a => a.Field<string>("ActualProvidedByCompany")).FirstOrDefault();
probably i tried to write Select() before where then i was getting error but the moment i place Select() after Where() then error gone. in sql we write select first and then filter. in LINQ can't we use select before WHERE() ?
tell me why i was getting error when i place select() before where() ?
please discuss my 2 question with example to better understand. thanks
Continue reading...