c# - Left outer join in LINQ is showing exception -
i getting following exception:
the null value cannot assigned member type system.int32 non- nullable value type.
below linq statement questionid primary key in table:
var questionviewsdata = questionviews in objdc.sc_questionsviews join questions in objdc.sc_questions on questionviews.questionid equals questions.questionid qs questions in qs.defaultifempty() questionviews.createddate.date == new datetime(2010, 4,27) select new { selected =(questions == null ?-1:questions.questionid), questiointitle = questions.title, votescount = questions.votescount };
change line
where questionviews.createddate.date == new datetime(2010, 4,27)
to
where questionviews.createddate == new datetime(2010, 4, 27)
as test run
where questionviews.createddate > new datetime(2010, 4, 26)
n.b. if include .date in linqpad c# statement receive following error message , removing .date allows statement run.
system.nullable<system.datetime>' not contain definition 'date' , no extension method 'date' accepting first argument of type 'system.nullable<system.datetime>' found
Comments
Post a Comment