This is a good softball of a question for Friday, but I have the following line of code:
// System.ArgumentOutRangeException If no match data is not turned on, then generated is Answers = New CurrentAnswersCollection (). Where ("PARTICIPANT_ID", 10000) .load () [0];
CurrentAnswersCollection is a strongly typed collection that has been populated by returning back to my database. The problem of the curriculum is that if there is no related PARTICIPANT_ID = 10000, I get the error message.
Is there a better way to write that I will not get the error message at all? I just know that there is not enough information about LINQ syntax if I can test for existence first?
Thanks
Use this:
CurrentAnswers = new current statement clearing (). Where ("PARTICIPANT_ID", 10000) .load (). FirstOrDefault ();
If there is no first element then it will return to zero.
But you may need to fix your code (duplicated before) - . Where
looks syntax cyclical.
Comments
Post a Comment