【发布时间】:2013-10-29 00:26:04
【问题描述】:
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 查询,如果不满足 where,在 PreviousAttempts 字段中我会得到空值。因此,我不想包含 null,如果它包含 null,我想更改这个 0,如果它不包含非 null 值,则恢复原始值。
由于我无法为每条记录更改PreviousAttempts,我该如何实现?
【问题讨论】: