Select column based on variable in LINQ to SQL

前端 未结 5 1522
眼角桃花
眼角桃花 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:40

    I'm not sure that I understand your question completely, so this might be a bit off. But could your problem perhaps be solved by using the LINQ Dynamic Query Library?

    You can use the DynamicQuery library against any LINQ data provider (including LINQ to SQL, LINQ to Objects, LINQ to XML, LINQ to Entities, LINQ to SharePoint, LINQ to TerraServer, etc). Instead of using language operators or type-safe lambda extension methods to construct your LINQ queries, the dynamic query library provides you with string based extension methods that you can pass any string expression into.

    See the above link for samples and downloads.

提交回复
热议问题