I'm sure this is something rather easy, but this is the first time I'm trying to do a save like this.
I have a Customer Table and an Entity Table 1:1 EntityID as PK (int, identity) Customer
I have a type Customer that is a sub-type of Entity.
So I update my customer fields (that include entity fields)
CustomerEntity _customer = new CustomerEntity();
_customer.Name = _name;
_customer.CustomerCode = "001"; //from Customer table
_customer.IsActive = _isActive; //From Entity table
_customer.CrtdUser = _lastUpdate_User; //from entity Table
_customer.UId = Guid.NewGuid(); //from Entity Table
_adapter.Save(_customer, true);
So the way I understand it. this should Update the supertype (Entity with the Entity information) and then update the Sub-Type with the PK of the supertype.
It's failing saying that you can't insert NULL into the field EntityID in table customer. I looked at the generated SQL
declare @p3 int
set @p3=8
exec sp_executesql N'INSERT INTO [MyDB].[dbo].[Entity] ([Crtd_User], [LastUpdate_User], [IsActive], [uID]) VALUES (@CrtdUser,
@LastUpdateUser, @IsActive, @UId);SELECT @EntityId=SCOPE_IDENTITY()',N'@EntityId int output,@CrtdUser varchar(50),@LastUpdateUser
varchar(50),@IsActive bit,@UId uniqueidentifier',@EntityId=@p3
output,@CrtdUser='ME',@LastUpdateUser='ME',@IsActive=1,@UId='668AB43D-76D8-4EB2-89B7-DFB550D3FD75'
select @p3
The above statement works correctly, the second statement fails
declare @p4 int
set @p4=NULL
exec sp_executesql N'INSERT INTO [MyDB].[dbo].[Customer] ([CustomerCode], [Name]) VALUES (@CustomerCode,
@Name);SELECT @CustomerId=SCOPE_IDENTITY()',N'@CustomerCode varchar(15),@CustomerId int output,@Name
varchar(50)',@CustomerCode='001',@CustomerId=@p4 output,@Name='1'
select @p4
This statement fails, and you'll notice that it never attempts to insert anything into the CustomerID field.
I'm sure I'm missing something simple here, is there a section in the manual that describes insert process for Sub-Types?
EDIT:
I just tried this with another Entity and it works, that one has the same Field Name as the PK in Entity (EntityID) Example Table Entity (EntityID PK), Table Vendor EntityID(PK,FK). Do I have to make them the same name (i.e. EntityID) for the Synch to occur?
TIA,
Justin