当前位置 : 主页 > 编程语言 > c语言 >

VB Linq转到C#Linq

来源:互联网 收集:自由互联 发布时间:2021-06-24
请帮我转换为C#等价物 Dim dtData As DataTable = Session("Data")Dim aFilters = From oRow In dtData _Where oRow(i_oColumn.BaseColumnName) IsNot DBNull.Value _Select sFilter = _oRow.Field(Of String)(i_oColumn.BaseColumnName).Replace(""
请帮我转换为C#等价物

Dim dtData As DataTable = Session("Data")

Dim aFilters = From oRow In dtData _
Where oRow(i_oColumn.BaseColumnName) IsNot DBNull.Value _
Select sFilter = _
oRow.Field(Of String)(i_oColumn.BaseColumnName).Replace("""", "\""") _
Distinct Order By sFilter
未经测试,但直接翻译(有些整理):

DataTable data = (DataTable)Session["Data"];

var filters= (from row in data.AsEnumerable()
              where !(row[i_oColumn.BaseColumnName] is DBNull)
              let result = (row.Field<string>(i_oColumn.BaseColumnName))
                                               .Replace(@"""",@"\""")
              orderby result
              select result).Distinct();

但是,我怀疑:

where !row.IsNull(i_oColumn.BaseColumnName)

woulc更清楚

网友评论