S
Sudip_inn
Guest
suppose i have class which has few properties like
section, Lineitem, XfundCode, Periods, order
my sample data. section and line item will be order by OrderID field. and period data will be show a order like below one
2010 FY, 2011 FY, 1Q 2012, 2Q 2012, 3Q 2012, 4Q 2012, 2012 FY, 1Q 2013,2Q 2013,3Q 2013, 4Q 2013, 2013 FY
value should come under period
List<Data> _lstTickerSectionLI = new List<Data>
{
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2010 FY",
Values = 2010
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2011 FY",
Values = 669
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "1Q 2012",
Values = 777.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2Q 2012",
Values = 7000.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "3Q 2012",
Values = 587.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "4Q 2012",
Values = 111
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2012 FY",
Values = 888
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "1Q 2013",
Values = 0999
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2Q 2013",
Values = 7412.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "3Q 2013",
Values = 125.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "4Q 2013",
Values = 111
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2013 FY",
Values = 555
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2010 FY",
Values = 2541
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2011 FY",
Values = 1287
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "1Q 2012",
Values = 4125.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2Q 2012",
Values = 7000.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "3Q 2012",
Values = 8541.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "4Q 2012",
Values = 0125
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2012 FY",
Values = 9632
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "1Q 2013",
Values = 3214
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2Q 2013",
Values = 7412.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "3Q 2013",
Values = 125.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "4Q 2013",
Values = 6521
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2013 FY",
Values = 9688
},
};
here giving a screen shot
as per the image above this way i want to show data. so guide me how could i use pivot technology in c# using LINQ if required. please share a sample code which help me to generate above output with data stored in List<T>. thanks
Continue reading...
section, Lineitem, XfundCode, Periods, order
my sample data. section and line item will be order by OrderID field. and period data will be show a order like below one
2010 FY, 2011 FY, 1Q 2012, 2Q 2012, 3Q 2012, 4Q 2012, 2012 FY, 1Q 2013,2Q 2013,3Q 2013, 4Q 2013, 2013 FY
value should come under period
List<Data> _lstTickerSectionLI = new List<Data>
{
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2010 FY",
Values = 2010
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2011 FY",
Values = 669
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "1Q 2012",
Values = 777.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2Q 2012",
Values = 7000.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "3Q 2012",
Values = 587.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "4Q 2012",
Values = 111
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2012 FY",
Values = 888
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "1Q 2013",
Values = 0999
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2Q 2013",
Values = 7412.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "3Q 2013",
Values = 125.20
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "4Q 2013",
Values = 111
},
new Data
{
OrderID = 1,
Section = "Consensus Model",
Lineitem = "Net Revenue",
XFundCode = "TRIN",
Period = "2013 FY",
Values = 555
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2010 FY",
Values = 2541
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2011 FY",
Values = 1287
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "1Q 2012",
Values = 4125.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2Q 2012",
Values = 7000.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "3Q 2012",
Values = 8541.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "4Q 2012",
Values = 0125
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2012 FY",
Values = 9632
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "1Q 2013",
Values = 3214
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2Q 2013",
Values = 7412.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "3Q 2013",
Values = 125.20
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "4Q 2013",
Values = 6521
},
new Data
{
OrderID = 2,
Section = "Consensus Model",
Lineitem = "Cost of Revenue",
XFundCode = "TRIN",
Period = "2013 FY",
Values = 9688
},
};
here giving a screen shot
as per the image above this way i want to show data. so guide me how could i use pivot technology in c# using LINQ if required. please share a sample code which help me to generate above output with data stored in List<T>. thanks
Continue reading...