Parent/Child ForeignKeyConstraint

R

Ross

http://groups.google.com/group/micr...aint"+child+key&rnum=3&hl=en#f2e7addd569723d6

I am experiencing this exact same problem with the Enterprise Library.
I have a DataSet. Parent table and Child table. I add a new row to
each. The parent key is an identity and it starts at -1. I assign -1 to
the related child key.

When I call UpdateDataSet for Parent, the identity comes back from the
database and I see the new key in both the Child and Parent rows of the
dataset. However, when I call UpdateDataSet on the Child table, the SQL
profiler shows the old "new" value of -1.

I am going to continue looking for a workaround but in the meantime I
thought I'd ask the Q.
 
R

Ross

I am going to guess this may be a bit of a bug with the DataSet. If any
record already exists in the child table that in someway relates to the
parent then the code works (I am not exactly sure of the correct
combinations because my child table is a junction table and the other
parent key already exists).

I can hack it by not adding the child row to the dataset until AFTER
the update is called for the parent. Ugly as it breaks my nice generic
interface of looping through a collection of business objects and
calling save. Thank goodness I am not trying to do this with a grid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top