You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SqliteConnection.Query<T> throws exception "CommandBehavior 'SingleResult, SequentialAccess' is invalid" from Microsoft.Data.Sqlite.dll #441
Executing a simple query is throwing an exception. I'm creating a ASP.NET 5 / .NET Core 1.0 project using latest beta of Dapper.NET (1.50.0-beta7) with a SQLite db.
usingDapper;usingMicrosoft.Data.Sqlite;...var connectionString ="Data Source=./db/test.db";using(varconnection=newSqliteConnection(connectionString)){connection.Open();connection.Execute(@" CREATE TABLE IF NOT EXISTS [DinosaurTypes] ( [Id] UUID NOT NULL PRIMARY KEY, [Name] NVARCHAR(200) NOT NULL )");connection.Execute(@" INSERT INTO [DinosaurTypes] (Id, Name) VALUES ('A1A38605-08D0-4695-A037-514A997FABF1', 'Stegosaurus')");// This throws a InvalidArgument exception.varresults=connection.Query<DinosaurType>("SELECT * FROM [DinosaurTypes]");// This works of course without the mapping to a model.varcommand=newCommandDefinition("SELECT * FROM [DinosaurTypes]");using(varreader=connection.ExecuteReader(command,CommandBehavior.Default)){object[]values=newobject[2];while(reader.Read()){reader.GetValues(values);}}}
It appears Dapper wants to set CommandBehavior.SingleResult on the DataReader (for performance reasons?), but the SQLite adapter doesn't support that. Is there a fix planned for this, or am I missing something?
This is the first I've heard of it; holy wow, that's a terrible thing for the SQLite adapter to do. If you can't support a suggested optimization, you (the adapter) should just carry on as normal - you shouldn't throw. That's really sucky, and IMO very definitely a bug in the SQLite adapter. I'll see if I can log it there. This would definitely break all recent dapper builds for SQLite. I'll investigate.
Activity
mgravell commentedon Jan 23, 2016
This is the first I've heard of it; holy wow, that's a terrible thing for the SQLite adapter to do. If you can't support a suggested optimization, you (the adapter) should just carry on as normal - you shouldn't throw. That's really sucky, and IMO very definitely a bug in the SQLite adapter. I'll see if I can log it there. This would definitely break all recent dapper builds for SQLite. I'll investigate.
NickCraver commentedon Jan 26, 2016
Issue created in the provider repo: aspnet/Microsoft.Data.Sqlite#220
NickCraver commentedon Jan 27, 2016
I've submitted a pull request to hopefully fix this behavior soon: aspnet/Microsoft.Data.Sqlite#221
NickCraver commentedon May 20, 2018
This is now fixed in the framework (
Microsoft.Data.Sqlite). Thanks for the report!