Linq To SQL - Specified cast is not valid - SingleOrDefault()
Posted
by NullReference
on Stack Overflow
See other posts from Stack Overflow
or by NullReference
Published on 2010-03-12T21:53:12Z
Indexed on
2010/03/12
21:57 UTC
Read the original article
Hit count: 730
LINQ
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.DataQuery1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable
1 source)
at GDRequestProcessor.Worker.GetNextRequest()
Can anyone help me? Thanks in advance!
© Stack Overflow or respective owner