Linq To SQL - Specified cast is not valid - SingleOrDefault()
- by NullReference
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](IQueryable1 source)
at GDRequestProcessor.Worker.GetNextRequest()
Can anyone help me?
Thanks in advance!