VB Linq转到C#Linq

请帮我转换为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更清楚

转载注明原文:VB Linq转到C#Linq - 代码日志