VB Linq - C # Linq

Please help me convert it to C # equivalent

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 
+4
source share
1 answer

Unconfirmed, but rather correct translation (with some utilization):

 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(); 

I suspect, however, that:

  where !row.IsNull(i_oColumn.BaseColumnName) 

woulc be clearer

+3
source

All Articles