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

Can Query<int> be made safer? #1255

Open
betty-crokker opened this issue Oct 15, 2024 · 0 comments
Open

Can Query<int> be made safer? #1255

betty-crokker opened this issue Oct 15, 2024 · 0 comments

Comments

@betty-crokker
Copy link

I just needed the Id column from a table so I did this:
var ids = db.Query<int>("select id from Data where channel=?", [channel]);
and it happily returned a List with a single value of zero.
The answer, of course, is:
var ids = db.QueryScalars<int>("select id from Data where channel=?", [channel]);

I see now that Query<> has to have a table type and that you can't specify a query that returns anything except entire rows.
Why, though, did it happily return a List instead of some kind of error? Is there a way to add error checking so it "notices" the mistake?

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

1 participant