Luminous
Luminous

Reputation: 1909

What linq reference am I missing?

I'm in .NET Framework 4.0, have imports System.Linq and System.Data.Linq at the top. I'm querying an object of type DataTable. Plus I have System.Data.Linq, System.Xml.Linq, and System.Data as references.

Why am I still getting Expression of type 'System.Data.DataTable' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider?

My LINQ query:

dim count = (from row in changes select row.field(of String)("UnitID") distinct).count()

Upvotes: 1

Views: 4568

Answers (1)

Duanne
Duanne

Reputation: 764

Try

dim count = (from row in changes.AsEnumerable() select row.field(of String)("UnitID") distinct).count()

MSDN - DataTableExtensions.AsEnumerable Method

The Select Method works for Enumerable or Queryable objects:

Queryable.Select

Enumerable.Select

Upvotes: 1

Related Questions