var records = from entity in q1.question_papers
select new
{
QuestionPaperID = entity.QUESTION_PAPER_ID,
SubjectID = entity.SUBJECT_ID,
PreviousAttempts = SubIdAtt.Where(c => c.SUBID == entity.SUBJECT_ID)
.Select(c => c.ATT)
.FirstOrDefault(),
};
上面是我的linq查詢,其中PreviousAttempts
字段我得到空值如果不滿足where。因此,如果不包含空值,我想將其更改爲0(如果它包含null),並且如果它不包含非空值,則還原原始值。包含空值的Linq查詢
我該如何做到這一點,因爲我無法爲每個記錄更改PreviousAttempts
?