Left outer join in LINQ is showing exception
- by stackuser3
The folloqing is the excpetion I am getting
The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type.
below is my LINQ Statement where QuestionId is the primary key in my table
var questionViewsData = from questionViews in objDc.SC_QuestionsViews
join questions in objDc.SC_Questions
on questionViews.QuestionId equals questions.QuestionId into qs
from questions in qs.DefaultIfEmpty()
where questionViews.CreatedDate.Date == new DateTime(2010, 4,27)
select new
{
Selected =(questions == null ?-1:questions.QuestionId),
QuestioinTitle = questions.Title,
VotesCount = questions.VotesCount
};
Let me know how to resolve this