Skip to content

Bug: QueryAsync interfering with PK #1046

@dendism

Description

@dendism

Bug Description

Calling QueryAsync is interfering with PK in an unexpected and unwanted way.

Exception Message:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Schema and Model:

DROP TABLE IF EXISTS [dbo].[RepoDbTest];
GO

CREATE TABLE [dbo].[RepoDbTest]
(
	[Id] [uniqueidentifier] NOT NULL CONSTRAINT DF_RepoDbTest_Id DEFAULT newsequentialid(),
	[Zdroj] [char](1) NOT NULL,
	[IdReklamacie] [varchar](8) NOT NULL,
	[IdStavu] [int] NOT NULL,
	[DatumStavu] [datetime2](7) NOT NULL,
	[Zmenil] [nvarchar](255) NOT NULL,
	[Poznamka] [nvarchar](2048) NOT NULL,
    CONSTRAINT [PK_RepoDb_Id] PRIMARY KEY CLUSTERED 
    (
        [Id] ASC
    )
);
GO

INSERT INTO [dbo].[RepoDbTest](Zdroj, IdReklamacie, IdStavu, DatumStavu, Zmenil, Poznamka)
    VALUES ('P', '07900736', 1, SYSDATETIME(), 'nobody', '')
            ,('P', '07900736', 2, SYSDATETIME(), 'nobody', '')
            ,('P', '07900737', 1, SYSDATETIME(), 'nobody', '')
            ,('P', '07900737', 2, SYSDATETIME(), 'nobody', '')
            ,('P', '07900737', 3, SYSDATETIME(), 'nobody', '');
GO

And also the model that corresponds the schema.

    [Map("RepoDbTest")]
    public sealed class RepoDbTestModel
    {
        public Guid Id { get; set; }
        public string Zdroj { get; set; }
        public string IdReklamacie { get; set; }
        public int IdStavu { get; set; }
        public DateTime DatumStavu { get; set; }
        public string Zmenil { get; set; }
        public string Poznamka { get; set; }
    }

Code:

using var cnn = new Microsoft.Data.SqlClient.SqlConnection(MainConnectionString);
var whereFilter = new[] { "07900736", "07900737" };
var records = await cnn.QueryAsync<RepoDbTestModel>(e => whereFilter.Contains(e.IdReklamacie));

Library Version:

Example: RepoDb v1.12.10 and RepoDb.SqlServer v1.1.5

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixedThe bug, issue, incident has been fixed.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions