How LINQ group by can return those fields which are not included in group by clause

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
does the below LINQ code doing the group by Section, LineItem & XFundCode ?

var tickerBrokerStandardDateLineitemValuesGroups =
(from tickerBrokerStandardDateLineitemValue in TickerBrokerStandardDateLineitemValues
group tickerBrokerStandardDateLineitemValue by new
{
Section = tickerBrokerStandardDateLineitemValue.TabName,
LineItem = tickerBrokerStandardDateLineitemValue.StandardLineItem,
XFundCode = tickerBrokerStandardDateLineitemValue.XFundCode,
} into tickerBrokerStandardDateLineitemValuesGroup
select tickerBrokerStandardDateLineitemValuesGroup);



How LINQ join return those column name which does not exist in group by clause ?. normally when we group then we can select those fields which are included in group by clause...but
here LINQ returning all fields after group on Section, LineItem & XFundCode.

above query doing group on this data source. small data snippet added in xml format

<?xml version="1.0" encoding="utf-8"?>
<TickerBrokerStandardDateLineitem>
<Ticker />
<TickerID />
<TickerBrokerStandardDateLineitemValues>
<TickerBrokerStandardDateLineitemValue>
<TabName>Consensus Model</TabName>
<StandardDate>2010 FY</StandardDate>
<XFundCode>TRIN</XFundCode>
<BRTab></BRTab>
<BRLineItem></BRLineItem>
<StandardLineItem>Total Sales</StandardLineItem>
<StandardValue></StandardValue>
<ActualProvidedByCompany>NO</ActualProvidedByCompany>
</TickerBrokerStandardDateLineitemValue>
<TickerBrokerStandardDateLineitemValue>
<TabName>Consensus Model</TabName>
<StandardDate>2011 FY</StandardDate>
<XFundCode>TRIN</XFundCode>
<BRTab></BRTab>
<BRLineItem></BRLineItem>
<StandardLineItem>Total Sales</StandardLineItem>
<StandardValue></StandardValue>
<ActualProvidedByCompany>NO</ActualProvidedByCompany>
</TickerBrokerStandardDateLineitemValue>
</TickerBrokerStandardDateLineitemValues>
</TickerBrokerStandardDateLineitem>
please explain. thanks

Continue reading...
 
Back
Top