InvalidCastException - "Devart.Data.Linq.DataQuery to Sys...

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Posts: 9
Joined: Sun 06 Sep 2009 15:09

InvalidCastException - "Devart.Data.Linq.DataQuery to Sys...

Post by Falke » Sun 06 Sep 2009 15:13


I am using LINQ.i created the datacontext object and i want to have a list back from the query. By doing that like:

Dim a as List(Of context.user) = From c in db.user Select c Order By c.Name Descending

i got an error:

InvalidCastException - "Devart.Data.Linq.DataQuery to Type System.Collections.Generic.List

How can i solve it?

Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 07 Sep 2009 14:49

Your expression can be cast to IList by calling the System.Linq.Enumerable.ToList method. Please pay attention to types of the left and right sides of assigning to make the right cast in the future. For more information, please refer to the LINQ documentation in MSDN.

Post Reply