For some reason I am having trouble with the fairly straight forward task of creating a new entity with a relationship. I have a Product Entity and a Variant Entity with a 1:m relationship. I create a new variant in the following way:
public static void AddNewVariant(string descriptor, ProductEntity product)
{
VariantEntity variant = new VariantEntity();
variant.Descriptor = descriptor;
variant.Product = product;
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.SaveEntity(product);
}
In debug mode I can see that the fk_id is set correctly in the entity, but for some reason when the adapter saves the entity, the setting of the foreign key value has an output direction and not an input direction, thus a SQL Null error is thrown. Here is the generated SQL:
Query: INSERT INTO [dev_QubicECommerce].[dbo].[ProductVariant] ([Descriptor]) VALUES (@Descriptor);SELECT @Pk_ID=SCOPE_IDENTITY();SELECT @Fk_ProductID=SCOPE_IDENTITY()
Parameter: @Pk_ID : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Output. Value: <undefined value>.
Parameter: @Fk_ProductID : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Output. Value: 1.
Parameter: @Descriptor : AnsiString. Length: 50. Precision: 0. Scale: 0. Direction: Input. Value: "Test Descriptor".
I am using Adapter templates with version 2.5 Beta.
Apologies if I am just missing something obvious. Thanks for any help