LINQ - Select Statement - The null value cannot be assigned to a member with type System.Int32 which

Posted by thiag0 on Stack Overflow See other posts from Stack Overflow or by thiag0
Published on 2010-03-15T16:23:59Z Indexed on 2010/03/15 16:29 UTC
Read the original article Hit count: 266

Filed under:

I am trying to achieve the following...

 _4S.NJB_Request request =
                (from r in db.NJB_Requests
                 where r.RequestId == referenceId
                 select r).Take(1).SingleOrDefault();

Getting the following exception...

    Message:
The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type.


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 DAL.SqlDataProvider.MarkNJBPCRequestAsComplete(Int32 referenceId, Int32 processState)

I have verified that 'referenceId' does have a value.

Anyone know why this would happen in a select statement?

Thanks!

© Stack Overflow or respective owner

Related posts about LINQ