addTo where the inserted table has a foreign key
Posted: Wed 04 Feb 2009 20:50
I have a simple datamodel - two tables
Product table
ID - string
DESC - string
CATEGORY_ID - string
Category table
ID - string
DESC - string
I have a foeign key constraint defined in the database for the product table Category_ID must equal Category.ID
I create my entity model, service, service reference, run datasvcutil etc. all is working for the most part
When I try to create a new Product I use
dim aNewProduct as new PRODUCT
aNewProduct.ID = "TEST"
aNewProduct.DESC = "TEST"
dim aCategory as new CATEGORY
aCatogory.ID = 'EXSTING CATEGORY ID'
aNewProduct.Category = aCategory
myService.AddToPRODUCT(aNewProduct)
My new product row shows up in the database but the CATEGORY_ID is null
I've also tried running a linq query and getting a CATEGORY entity and setting the aNewProduct.Category to the existing CATEGORY entity. I have also tried the simple aNewProduct.Category_ID = 'EXSTING CATEGORY ID'
Does anyone have a way to do this?
Thanks
Product table
ID - string
DESC - string
CATEGORY_ID - string
Category table
ID - string
DESC - string
I have a foeign key constraint defined in the database for the product table Category_ID must equal Category.ID
I create my entity model, service, service reference, run datasvcutil etc. all is working for the most part
When I try to create a new Product I use
dim aNewProduct as new PRODUCT
aNewProduct.ID = "TEST"
aNewProduct.DESC = "TEST"
dim aCategory as new CATEGORY
aCatogory.ID = 'EXSTING CATEGORY ID'
aNewProduct.Category = aCategory
myService.AddToPRODUCT(aNewProduct)
My new product row shows up in the database but the CATEGORY_ID is null
I've also tried running a linq query and getting a CATEGORY entity and setting the aNewProduct.Category to the existing CATEGORY entity. I have also tried the simple aNewProduct.Category_ID = 'EXSTING CATEGORY ID'
Does anyone have a way to do this?
Thanks