表:
CREATE TABLE [dbo].[Test](?[PKID] [uniqueidentifier] NOT NULL,?[Name] [nvarchar](50) NULL,?[AA] [nchar](10) NULL,?[BB] [nchar](10) NULL,?[CC] [nchar](10) NULL,?[DD] [nchar](10) NULL,?[EE] [nchar](10) NULL,?[FF] [nchar](10) NULL,?[TestType] [tinyint] NULL,?CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED (?[PKID] 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
?
實(shí)體:
public abstract class Test : Entity??? {??????? [Key]??????? public Guid PKID { get; set; }??????? public string Name { get; set; }??? }
??? public class A : Test??? {??????? public string BB { get; set; }??????? public string CC { get; set; }??????? public string DD { get; set; }??? }??? public class B : Test??? {??????? public string AA { get; set; }??????? public string BB { get; set; }??????? public string CC { get; set; }??????? public string DD { get; set; }??? }??? public class C : Test??? {??????? public string EE { get; set; }??????? public string FF { get; set; }??? }
?
??????????? modelBuilder.Entity<Test>()??????????? .Map<A>(m => m.Requires("TestType").HasValue((byte)0))??????????? .Map<B>(m => m.Requires("TestType").HasValue((byte)1))??????????? .Map<C>(m => m.Requires("TestType").HasValue((byte)2));
?
當(dāng)向A實(shí)體插入記錄時,生成下面sql:
exec sp_executesql N'insert [dbo].[Test]([PKID], [Name], [BB], [CC], [DD], [AA], [BB1], [CC1], [DD1], [EE], [FF], [TestType])values (@0, @1, @2, @3, @4, null, null, null, null, null, null, @5)',N'@0 uniqueidentifier,@1 nvarchar(max) ,@2 nvarchar(max) ,@3 nvarchar(max) ,@4 nvarchar(max) ,@5 tinyint',@0='B1264CFD-8E16-451D-B015-E9CE756EC7F9',@1=N'A',@2=N'bb',@3=N'cc',@4=N'dd',@5=0
請問為何BB,CC,DD變成了BB1,CC1,DD1?
- 2 回答
- 0 關(guān)注
- 364 瀏覽
添加回答
舉報
0/150
提交
取消