jaquel / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

"select count(*)" not working with SQLite3 - System.InvalidCastException #152

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following code snippet:

using (var conn = new SQLiteConnection(...)) {
    conn.Query<int>("select count (*) from Foo;").Single();
}

throws an InvalidCastException with the error message: "Specified cast is not 
valid." All the other expetiment I'm doing, seems to work fine. I'm using 
SQLite3 and Dapper 1.12.1.1.

Original issue reported on code.google.com by giulio.p...@gmail.com on 29 Aug 2013 at 4:34

GoogleCodeExporter commented 9 years ago
Are you sure it is returning an int and not, for example, a long?

Original comment by ane...@abyssal.eu on 13 Nov 2013 at 2:34

GoogleCodeExporter commented 9 years ago
Actually, I've abandoned the project... and quit the company :-) so cannot 
reproduce the bug in order to check. Sorry.

Original comment by giulio.p...@gmail.com on 13 Nov 2013 at 2:40

GoogleCodeExporter commented 9 years ago
I ran into the same issue. count(*) comes back from SQLite as long, not int. 
Changing to long fixed it for me.

Original comment by superson...@gmail.com on 9 Dec 2013 at 10:09

GoogleCodeExporter commented 9 years ago
With recent changes (not yet on nuget), all numbers are a lot happier to be 
interchangeable

Original comment by marc.gravell on 6 Aug 2014 at 3:35