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

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

Postby 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?
Posts: 9
Joined: Sun 06 Sep 2009 15:09

Postby 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.
Devart Team
Posts: 7945
Joined: Thu 14 Aug 2008 12:44

Return to dotConnect for MySQL