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

Insufficient parameters supplied to the command #292

Open
todor-dk opened this issue Jan 3, 2022 · 0 comments
Open

Insufficient parameters supplied to the command #292

todor-dk opened this issue Jan 3, 2022 · 0 comments
Assignees
Labels

Comments

@todor-dk
Copy link

todor-dk commented Jan 3, 2022

Using the latest NuGet package 1.7.0, simple Update operations fail with the error: Insufficient parameters supplied to the command. This happens if there is a Guid property present on the entity. The same works in version 1.6.3.

Code to reproduce:

// Add reference to NuGet: System.Data.SQLite
// Add reference to NuGet: Dapper.Extensions

using Dapper;
using DapperExtensions;
using System.Data.SQLite;

public static void Main()
{
	string tempDb = Path.Combine(Path.GetTempPath(), $"DB_{Guid.NewGuid()}.sqlite");

	SQLiteConnection connection = new SQLiteConnection();
	connection.ParseViaFramework = true;
	connection.ConnectionString = $"data source=\"{tempDb}\";failifmissing=False;foreign keys=False;binaryguid=True";

	connection.Open();
	using (SQLiteCommand command = connection.CreateCommand())
	{
		command.CommandText = "CREATE TABLE [Entities] ([Id] guid PRIMARY KEY NOT NULL, [Name] text);";
		command.ExecuteNonQuery();
		command.CommandText = "INSERT INTO [Entities] ([Id], [Name]) VALUES ('02D16168-1E2E-4D5B-97E1-6CFCA3EF4B87', 'John');";
		command.ExecuteNonQuery();
	}

	DapperExtensions.DapperExtensions.SqlDialect = new DapperExtensions.Sql.SqliteDialect();
	DapperExtensions.DapperExtensions.DefaultMapper = typeof(DapperExtensions.Mapper.PluralizedAutoClassMapper<>);

	string sql = "SELECT * FROM [Entities]";
	Entity entity = connection.Query<Entity>(sql).ToArray().First();
	System.Diagnostics.Debug.Assert(entity.Name == "John");

	entity.Name = "Doe";
	connection.Update<Entity>(entity);  // <--- Fails Here !!!!

	connection.Close();
	File.Delete(tempDb);
}

private class Entity
{
	[System.ComponentModel.DataAnnotations.Key]
	public Guid Id { get; set; }

	public string Name { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants