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

Guid Primary Key is not being set if the Class Name is a Mapped Class #53

Closed
mikependon opened this issue Oct 21, 2018 · 1 comment
Closed
Assignees
Labels
bug Something isn't working deployed Feature or bug is deployed at the current release invalid This doesn't seem right

Comments

@mikependon
Copy link
Owner

[Map("DatabaseCheckActivity")]
public class DatabaseCheckActivityAllocation
{
public Guid Id { get; set; }
public long LargePageAllocationsInKb { get; set; }
public long LockedPageAllocationsInKb { get; set; }
public long TotalVirtualAddressSpaceInKb { get; set; }
public long VirtualAddressSpaceReservedInKb { get; set; }
public long VirtualAddressSpaceCommittedInKb { get; set; }
public long VirtualAddressSpaceAvailableInKb { get; set; }
}

var allocation = _serviceMonitorRepository
.Query<WebModels.DatabaseCheckActivityAllocation>(new { Id = databaseCheckId })
.Select(databaseCheckActivity => Convert(databaseCheckActivity))
.FirstOrDefault();


Result: The allocation.Id is an Empty Guid

@mikependon mikependon added the bug Something isn't working label Oct 21, 2018
@mikependon mikependon self-assigned this Oct 21, 2018
@mikependon mikependon added the invalid This doesn't seem right label Nov 10, 2018
@mikependon
Copy link
Owner Author

USE [TestDb]
GO

/****** Object: Table [dbo].[TestTable] Script Date: 11/10/2018 7:52:14 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[TestTable](
[Id] [uniqueidentifier] NOT NULL,
[Value] nvarchar NOT NULL,
CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

INSERT INTO [dbo].[TestTable] ([Id], [Value]) SELECT NEWID(), 'Test-1';
INSERT INTO [dbo].[TestTable] ([Id], [Value]) SELECT NEWID(), 'Test-2';
INSERT INTO [dbo].[TestTable] ([Id], [Value]) SELECT NEWID(), 'Test-3';


using RepoDb;
using RepoDb.Attributes;
using System;
using System.Data.SqlClient;

namespace TestQueryRepoDb
{
[Map("TestTable")]
public class Test
{
public Guid Id { get; set; }
public string Value { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
        using (var connection = new SqlConnection("Server=.;Database=TestDb;Integrated Security=True;"))
        {
            var tests = connection.Query<Test>();
        }
    }
}

}

@mikependon mikependon added the deployed Feature or bug is deployed at the current release label Nov 11, 2018
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 invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant