Linq : select value in a datatable column

前端 未结 7 476
广开言路
广开言路 2020-12-06 09:38

How do you use LINQ (C#) to select the value in a particular column for a particular row in a datatable. The equivalent SQL would be:<

相关标签:
7条回答
  • 2020-12-06 10:18
    var x  =  from row in table
              where row.ID == 0
              select row
    

    Supposing you have a DataTable that knows about the rows, other wise you'll need to use the row index:

    where row[rowNumber] == 0
    

    In this instance you'd also want to use the select to place the row data into an anonymous class or a preprepared class (if you want to pass it to another method)

    0 讨论(0)
提交回复
热议问题