Instead of using a bool I decided to just return the guid becuase I will need it anyway. I am having a hard time figuring out how to test for no returned reaults though. So I changed to the following. Is this solution ok? Or is there a better solution? From what I've read on msdn I can't find a better solution.
Before I insert an associate record I want to make sure the social security number isn't already in use.
According to msdn that exception will be throw if no records are found.Code:public Guid Asociates_CheckForSSN(string p_ssn) { Dbcontext dbc = new Dbcontext(); try { var assoc = dbc.Associates_CheckForSSN(p_ssn).Single(); return assoc.AssociateID; } catch(InvalidOperationException) { return Guid.Empty; } }
I will return the Guid of the Associate instead of returning bool.
But is traping this error a good solution or is there some better way to test for a null result?
Thanks.




Reply With Quote