How to build pivot table through linq using c#

前端 未结 2 1288
故里飘歌
故里飘歌 2020-12-04 02:26

I have got this datatable in my c# code:

Date     | Employee | Job1 | Job2 |  Job3 |
---------|----------|------|---         


        
2条回答
  •  悲&欢浪女
    2020-12-04 03:14

    You won't be able to do this with LINQ due to the dynamic nature of the columns. LINQ to SQL needs a static way to map result set fields to property values. Instead, you can look into the PIVOT SQL statement and fill the results into a DataTable

    http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx

提交回复
热议问题