I am writing a data access code, and I want to check the potentially โinvalidโ states of the data in the database. For example, I am returning a widget from a database, and I am only expecting it. If I get two, I want to throw an exception. Despite the fact that referential integrity should prevent this, I do not want to depend on database administrators who never change the scheme (to clarify this, if the primary key constraint is removed and I get cheated, I want to quickly and clearly break it down).
I would like to use a System.IO.InvalidDataException exception, except that I am not dealing with a file stream, so it is misleading. As a result, I came across a common application. Anyone have a better idea?
jslatts
source share