LINQ - Linq to Sql - Specified cast is not valid - Please Help!

Posted by thiag0 on Stack Overflow See other posts from Stack Overflow or by thiag0
Published on 2010-03-14T16:10:35Z Indexed on 2010/03/14 16:15 UTC
Read the original article Hit count: 252

Filed under:
|

I am trying to do the following...

Request request = (
     from r in db.Requests 
     where r.Status == "Processing" && r.Locked == false 
     select r).SingleOrDefault();

It is throwing the following exception...

Message:
Specified cast is not valid.

StackTrace:
   at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
   at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
   at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
   at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
   at GDRequestProcessor.Worker.GetNextRequest()

The .DBML file schema matches my database table that I am trying to select from so I have no clue why I am having this problem.

Can anyone help me?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about invalidcastexception