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

Bug: An identify field parameter issue is being thrown when invoking the MergeAll operation dynamically #849

Closed
mikependon opened this issue Jul 29, 2021 · 1 comment
Assignees
Labels
bug Something isn't working deployed Feature or bug is deployed at the current release fixed The bug, issue, incident has been fixed.

Comments

@mikependon
Copy link
Owner

mikependon commented Jul 29, 2021

Bug Description

When the method MergeAll is being invoked via dynamic approach, an identity field parameter issue is being thrown if the underlying schema/table has an identify field and if it weren't provided via the supplied list of dynamic objects even the other fields were defined as the qualifiers.

Exception Message:

Microsoft.Data.SqlClient.SqlException: 'Must declare the scalar variable "@id".
Statement(s) could not be prepared.'

image

Schema and Model:

Created adhocly, see below.

CREATE TABLE [sales].[Person]
(
	[Id] INT IDENTITY
	, [Name] NVARCHAR(256)
	, [DateOfBirth] DATETIME2(7)
	, [Address] NVARCHAR(MAX)
	, [DateInsertedUtc] DATETIME2(7)
) ON [PRIMARY];

No underlying model/class since the invocation is dynamic.

How to Replicate?

Simply call the method like below.

var people = new object[]
{
	new { Name = "Name1", DateOfBirth = DateTime.UtcNow.AddYears(-30), Address = "Address1", DateInsertedUtc = DateTime.UtcNow },
	new { Name = "Name2", DateOfBirth = DateTime.UtcNow.AddYears(-25), Address = "Address2", DateInsertedUtc = DateTime.UtcNow },
	new { Name = "Name3", DateOfBirth = DateTime.UtcNow.AddYears(-35), Address = "Address3", DateInsertedUtc = DateTime.UtcNow }
};
connection.MergeAll("[sales].[Person]", people, qualifiers: Field.From("Name", "Address"));

Library Version:

Example: RepoDb v1.12.8-beta4 and RepoDb.SqlServer v1.1.3

@mikependon mikependon added the bug Something isn't working label Jul 29, 2021
@mikependon mikependon self-assigned this Jul 29, 2021
@mikependon mikependon added the fixed The bug, issue, incident has been fixed. label Jul 29, 2021
@mikependon
Copy link
Owner Author

This will be available on the next version > RepoDb v1.12.8-beta4.

@mikependon mikependon added the deployed Feature or bug is deployed at the current release label Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deployed Feature or bug is deployed at the current release fixed The bug, issue, incident has been fixed.
Projects
None yet
Development

No branches or pull requests

1 participant