0

I have a DataTable which I am filtering by converting it to Enumerable as

_dt.AsEnumerable().Select(Function(s) s.Field(Of String)("LF").Trim().Contains(sFilter)).Take(25).Cast(Of DataRow).CopyToDataTable()

I am getting exception while execution as Unable to cast object of type 'System.Boolean' to type 'System.Data.DataRow'. Where I went wrong?

Bharadwaj
  • 2,535
  • 1
  • 22
  • 35

1 Answers1

1

You select Booleans as a result of the function. Try Using Where instead of select.

sdf
  • 189
  • 3
  • I'm guessing someone could post a better answer expalining the difference between selecting and filtering. http://stackoverflow.com/questions/1212746/linq-what-is-the-difference-between-select-and-where – sdf May 08 '14 at 08:27
  • Or you can edit the same with details. But this solve my issue. – Bharadwaj May 08 '14 at 09:27