Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Exceptions between FindBy() and FindAllBy() #186

Closed
hmobius opened this issue May 6, 2012 · 1 comment
Closed

Inconsistent Exceptions between FindBy() and FindAllBy() #186

hmobius opened this issue May 6, 2012 · 1 comment

Comments

@hmobius
Copy link

hmobius commented May 6, 2012

FindBy() and FindAllBy() produce different exceptions when being (erroneously) called the same way, as described below. They should throw the same exception and error message.

No column names and no column values.

Calling FindBy() throws System.ArgumentException : "FindBy requires arguments."
Calling FindAllBy() throws System.InvalidOperationException : "Sequence contains no elements"

Suggested throw : System.ArgumentException : "FindBy\FindAllBy requires at least one column name and value to filter data by"

One column name but no column value

Calling FindByGenreId() and FindAllByGenreId() both throw System.ArgumentException : "No parameter specified".
Suggest changing message to "FindBy\FindAllBy requires a equal number of column names and values to filter data by"

No column name but one column value

Calling FindBy(1) throws System.ArgumentException : "List initializers must contain at least one initializer"
Calling FindAllBy(1) throws System.InvalidOperationException : "Sequence contains no elements"

Suggested throw : System.ArgumentException : "FindBy\FindAllBy requires a equal number of column names and values to filter data by"

One column name with column value set to null

Calling FindByGenreId(null) throws Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : "Cannot perform runtime binding on a null reference"
Calling FindAllByGenreId(null) sends correct SQL to database searching for data where GenreId is null. Returns empty data set.

Suggest FindByGenreId(null) should return null or uninitialized SimpleRecord rather than throw an exception?

@hmobius
Copy link
Author

hmobius commented May 6, 2012

Oh, and one more

Calling FindBy(GenreId:null). Throws System.ArgumentException : "FindBy does not accept unnamed null argument."
Calling FindAllBy(GenreId:null) sends correct SQL to database searching for data where GenreId is null. Returns empty data set.

Suggest FindBy(GenreId:null) should either succeed and return null or uninitialized SimpleRecord OR throw the same exception as FindByGenreId(null)

markrendle added a commit that referenced this issue May 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants