Select column based on variable in LINQ to SQL

前端 未结 5 1566
眼角桃花
眼角桃花 2021-01-19 03:43

I\'m using LINQ to SQL in C# in my application. I need to be able to select a column of a row, depending upon a variable. This is easy for the row as it\'s a simple where cl

5条回答
  •  庸人自扰
    2021-01-19 04:36

    Is it possible to change your database structure so that your columns becomes rows? (Pivot your table?)

    Eg.

    Permissions Table
    -----------------
    Id
    Dashboardname
    Page1
    Page2
    Page3
    ...
    

    and turn it into

    Permissions Table
    -----------------
    Id
    Dashboardname
    Pagename
    

    Then you could use the where clause to select the row you want?

提交回复
热议问题