Click here to Skip to main content
15,905,971 members
Home / Discussions / C#
   

C#

 
QuestionGet the value from a checklistbox Pin
Luis M. Rojas5-May-21 6:35
Luis M. Rojas5-May-21 6:35 
AnswerRe: Get the value from a checklistbox Pin
Gerry Schmitz5-May-21 8:19
mveGerry Schmitz5-May-21 8:19 
GeneralRe: Get the value from a checklistbox Pin
Luis M. Rojas5-May-21 11:01
Luis M. Rojas5-May-21 11:01 
GeneralRe: Get the value from a checklistbox Pin
Gerry Schmitz5-May-21 11:18
mveGerry Schmitz5-May-21 11:18 
GeneralRe: Get the value from a checklistbox Pin
Richard MacCutchan5-May-21 21:16
mveRichard MacCutchan5-May-21 21:16 
AnswerRe: Get the value from a checklistbox Pin
Alan N6-May-21 4:06
Alan N6-May-21 4:06 
GeneralRe: Get the value from a checklistbox Pin
Luis M. Rojas7-May-21 3:30
Luis M. Rojas7-May-21 3:30 
QuestionHow convert SQL Server Pivot functionality in C# uisng LINQ Pin
Mou_kol3-May-21 5:45
Mou_kol3-May-21 5:45 
I am using SQL Server Pivot which works fine. Here is sample data below which transpose by SQL server pivot function. this is sample data which convert to pivot by SQL server.

+------------+--------------+-----------+--------------+--------+-------------+--------------------+----------+
     | RowNumber  |   Section    | LineItem  | DisplayInCSM | Broker | BrokerName  | ItemValue_NoFormat |  Period  |
     +------------+--------------+-----------+--------------+--------+-------------+--------------------+----------+
     |          1 | Operational  | NG Sales  | NGL          | CR     | Credit Suse |                200 | 2010 FYA |
     |          2 | Operational  | NG Sales  | NGL          | GR     | Max 1       |                300 | 2010 FYA |
     |          3 | Operational  | NG Sales  | NGL          | PX     | Morgan      |                100 | 2010 FYA |
     |          4 | Operational  | NG Sales  | NGL          | WB     | Wells Fargo |                500 | 2010 FYA |
     +------------+--------------+-----------+--------------+--------+-------------+--------------------+----------+



This is dynamic sql i used in sql server to represent data in pivot format. here it is.
C#
SET @SQL='SELECT *                                      
     FROM                                                                              
     (                      
       SELECT RowNumber,CAST(ISNULL(EarningID,0) AS INT) EarningID,    
       Section,    
       LineItem,    
       DisplayInCSM,     
       Type,     
       Broker,    
       BrokerName,     
       ItemValue_NoFormat,     
       TRIM(ISNULL(Period,'''')) Period,hierarchy,                
       from #tmpData1 WHERE TYPE<>''SHEET''                                                                      
     ) t                                                                              
     PIVOT                                                                              
     (                                                                              
      MAX(ItemValue_NoFormat)                                                                              
      FOR Broker IN ([5W], [8K], [CL], [DA], [EQ], [FA], [GS], [HM], [HQ], [JY], [KW], [ML], [MS], [MV], [SL], [UA],[WB])                                                                              
     ) AS P                                                                              
     order by hierarchy,PeriodOrder



Now due to some problem i have to use C# to pivot data which is stored in list. suppose my first sample stored in list now how can i pivot that data by c# LINQ.

i saw these post Is it possible to Pivot data using LINQ?
https://stackoverflow.com/questions/167304/is-it-possible-to-pivot-data-using-linq/6282689#6282689

Pivot data using LINQ
https://stackoverflow.com/questions/963491/pivot-data-using-linq

but still not clear to me how to write the code for my scenario which display broker name horizontally. so please some one give me some hint which help me to start the coding part as a result i can show my data in pivot format where broker name will be shown horizontally. thanks
QuestionRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
Eddy Vluggen3-May-21 6:10
professionalEddy Vluggen3-May-21 6:10 
AnswerRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
Mou_kol3-May-21 6:50
Mou_kol3-May-21 6:50 
GeneralRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
Eddy Vluggen3-May-21 6:57
professionalEddy Vluggen3-May-21 6:57 
GeneralRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
Gerry Schmitz3-May-21 7:49
mveGerry Schmitz3-May-21 7:49 
GeneralRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
Eddy Vluggen3-May-21 11:23
professionalEddy Vluggen3-May-21 11:23 
GeneralRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
Gerry Schmitz3-May-21 21:56
mveGerry Schmitz3-May-21 21:56 
GeneralRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
Pete O'Hanlon3-May-21 23:18
mvePete O'Hanlon3-May-21 23:18 
GeneralRe: How convert SQL Server Pivot functionality in C# uisng LINQ Pin
OriginalGriff4-May-21 1:34
mveOriginalGriff4-May-21 1:34 
QuestionBinding Textblock Text and Textbox Text Pin
mnkdrt3-May-21 4:09
mnkdrt3-May-21 4:09 
AnswerRe: Binding Textblock Text and Textbox Text Pin
Gerry Schmitz3-May-21 8:07
mveGerry Schmitz3-May-21 8:07 
QuestionDebug decompile - urgent project restore Pin
Ahmedtsadek2-May-21 19:05
Ahmedtsadek2-May-21 19:05 
AnswerRe: Debug decompile - urgent project restore Pin
OriginalGriff2-May-21 19:32
mveOriginalGriff2-May-21 19:32 
AnswerRe: Debug decompile - urgent project restore Pin
Kuolung19673-May-21 0:48
Kuolung19673-May-21 0:48 
AnswerRe: Debug decompile - urgent project restore Pin
Gerry Schmitz3-May-21 7:42
mveGerry Schmitz3-May-21 7:42 
GeneralRe: Debug decompile - urgent project restore Pin
Richard Andrew x643-May-21 10:32
professionalRichard Andrew x643-May-21 10:32 
GeneralRe: Debug decompile - urgent project restore Pin
Ahmedtsadek3-May-21 12:55
Ahmedtsadek3-May-21 12:55 
GeneralRe: Debug decompile - urgent project restore Pin
Gerry Schmitz3-May-21 21:41
mveGerry Schmitz3-May-21 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.