ADO.Net, XML, XSD, and Relationships

  • Thread starter Alejandro Calbazana
  • Start date
A

Alejandro Calbazana

Hello,

I am investigating how to incorporate xml into a dataset while
preserving parent/child relationships. I understand that I can read
in an xsd to define the structure of the data and relationships. What
I am less clean about is if it is possible to read in an xml document
that conforms to the xsd AND have parent child relationships resolved
for me as my records are inserted using ReadXml().

I ask this because I have a set of tables which contain autoincrement
fields. When the parent gets a new identity, it should be given to
the children records as they are inserted.

SQLXml Bulk Load seems to do this for me after I cobble together an
xsd to make this happen. However, I have additional processing that I
need to do, so bulk loading will not help me here.

I am considering a dataset but I'd like to confirm or eliminate the
possibility of using the relationships, as defined by the schema, to
propogate the keys as my child records are inserted using ReadXml().

I have confirmed that my xsd creates the proper relationships for me.
I have also added records by hand using the SetParentRow(parentRow)
method. I get back the results that I expect, but I am wondering if I
can get the same result by using ReadXml().

Any help is appreciated.

Thanks,

Alejandro
 
A

Alejandro Calbazana

Thanks for the reply.

Here is the scenario. I am developing a web service that dishes up a
dataset. This dataset contains several data tables with
relationships. Once this dataset is shipped down to the client, they
will manipulate it by adding records, removing records, etc...

The idea here is to add autoincrement fields to the dataset so that
once it reaches the client, all modifications will respect the
fidelity described in an annotated schema. Also, when the dataset is
first loaded, it should "fill in" the parent/child keys in the defined
autoincrement fields. So it might look something like this:

Before download on the server:

table_parent.PK_Field = 1
table_child.FK_Field = 1

After download on the cleint:

table_parent.PK_Field = 1
table_parent.TempPK_Field = -1

table_child.Fk_Field = 1
table_child.TempPK_Field = -1


My question is how to get these keys in place. I can see the
relationships in my dataset once it hits the client, but my keys are
not cascading the way I expect. My parent ID is set, but the child
IDs are left empty. Any samples on this?

Thanks,

Alejadnro
 

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