开发者

Subsonic2.2 and NEWSEQUENTIALID() Primary Key Column

Subsonic is returning 00000000-0000-0000-0000-000000000000 when I insert a record and try to get it's key after insert.

product.Save();
GUID = product.ProdID;

The record is inserted correctly with correct GUIDs.

Any idea on how to resolve this? I am using version 2.2.0.0

This is my table schema

GO

SET ANSI_NULLS ON
GO
SET QUO开发者_如何学GoTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ISA_810_ControlTracking](
    [ISAID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT     [DF_ISA_810_ControlTracking_ISAID]  DEFAULT (newsequentialid()),
    [ISA000_01_Authorization_Information_Qualifier] [varchar](2) NOT NULL,
    [ISA000_02_Authorization_Information] [varchar](10) NOT NULL,
    [ISA000_03_Security_Information_Qualifier] [varchar](2) NOT NULL,
    [ISA000_04_Security_Information] [varchar](10) NOT NULL,
    [ISA000_05_Interchange_Id_Qualifier] [varchar](2) NOT NULL,
    [ISA000_06_Interchange_Sender_Id] [varchar](15) NOT NULL,
    [ISA000_07_Interchange_Id_Qualifier] [varchar](2) NOT NULL,
    [ISA000_08_Interchange_Receiver_Id] [varchar](15) NOT NULL,
    [ISA000_09_Interchange_Date] [datetime] NOT NULL,
    [ISA000_10_Interchange_Time] [datetime] NOT NULL,
    [ISA000_11_Interchange_Control_Standards_Identifier] [varchar](1) NOT NULL,
    [ISA000_12_Interchange_Control_Version_Number] [varchar](5) NOT NULL,
    [ISA000_13_Interchange_Control_Number] [int] NOT NULL,
    [ISA000_14_Acknowledgment_Requested] [varchar](1) NOT NULL,
    [ISA000_15_Usage_Indicator] [varchar](1) NOT NULL,
    [ISA000_16_Component_Element_Separator] [varchar](1) NOT NULL,
    [IEA000_01_Number_Of_Included_Functional_Groups] [int] NOT NULL,
    [IEA000_02_Interchange_Control_Number] [int] NOT NULL,
 CONSTRAINT [PK_ISA_810_ControlTrackingIndex] PRIMARY KEY CLUSTERED 
(
    [ISAID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,     ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_ISA_810_ControlTracking] UNIQUE NONCLUSTERED 
(
    [ISA000_06_Interchange_Sender_Id] ASC,
    [ISA000_08_Interchange_Receiver_Id] ASC,
    [ISA000_13_Interchange_Control_Number] 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
SET ANSI_PADDING OFF


Unlike IDENTITY types, applications have no way of determining the generated GUID on insert. While this is possible in T-SQL by using OUTPUT clause: INSERT ... OUTPUT inserted.$ROWGUIDCOL VALUES(...) most ORMs won't know how to do this. Given that the guid is a guid and doesn't matter who generates it, I'd recommend you generate it in the client prior of saving a new record, using UuidCreateSequential.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜