当我插入一条记录并尝试在插入后获取密钥时,Subsonic将返回00000000-0000-0000-0000-000000000000。
product.Save();
GUID = product.ProdID;
使用正确的GUID正确插入记录。
有关如何解决此问题的任何想法?我使用的是2.2.0.0版本
这是我的表架构
GO
SET ANSI_NULLS ON
GO
SET QUOTED_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
答案 0 :(得分:0)
与IDENTITY类型不同,应用程序无法确定插入时生成的GUID。虽然这可以通过使用OUTPUT子句在T-SQL中实现:INSERT ... OUTPUT inserted.$ROWGUIDCOL VALUES(...)
大多数ORM都不知道如何执行此操作。鉴于guid是guid并且无关紧要谁生成它,我建议您在保存新记录之前使用UuidCreateSequential
在客户端生成它。