by Christopher Klein
on Stack Overflow
See other posts from Stack Overflow
or by Christopher Klein
Published on 2010-06-18T14:10:13Z Indexed on 2010/06/18 14:13 UTC
Read the original article Hit count: 206
Hoping this is a nice softball of a question for a friday but I have the following line of code:
//System.ArgumentOutOfRangeException generated if there is no matching data currentAnswers = new CurrentAnswersCollection().Where("PARTICIPANT_ID", 10000).Load();
CurrentAnswersCollection is a strongly-typed collection populated by a view going back to my database. The problem of course is that if there is not a corresponding PARTICIPANT_ID = 10000 I get the error message.
Is there a better way to write this so that I wouldn't get the error message at all? I just dont know enough about LINQ syntax to know if I can test for the existance first?
© Stack Overflow or respective owner