0
我有用LINQ製作WHERE子句的問題。我試圖谷歌它,但我只有如何處理如果外部變量是可空的整數類型的答案......嗯,我試過這些方法相反(我有0 ... 1關係在我的數據集中): 例如LINQ的WHERE子句其中COLUMN可能爲空
int oldId = oldQuestion.id;
IEnumerable<possible_answer> possibleAnswersQuery =
from x in Mentor11Entities.possible_answers
where object.Equals(x.question_id, oldId)
select x;
List<possible_answer> possibleAnswers =
possibleAnswersQuery.ToList<possible_answer>();
或
int oldId = oldQuestion.id;
IEnumerable<possible_answer> possibleAnswersQuery =
from x in Mentor11Entities.possible_answers
where Convert.ToInt32(x.question_id ?? 0).Equals(oldId)
select x;
List<possible_answer> possibleAnswers =
possibleAnswersQuery.ToList<possible_answer>();
,但我一直都想與這LINQ不支持某些功能的錯誤......有沒有什麼辦法來解決這個問題?
噢,我的,它的工作......太簡單找出。謝謝! :) – smsware 2012-07-18 05:02:08
@sms,不客氣 – Habib 2012-07-18 05:03:05