Hi there
I have a problem here with the SQL query. I get a parameter @xmlObject of ntext type which contains the data objects in xml format. Like this:
<Employees>
<Employee EmployeeID="1" Name="John">
<Properties>
<Property EmployeeID="1" PropertyID="1" Value="age">
</Property>
<Property EmployeeID="1" PropertyID="2" Value="height">
</Property>
</Properties>
</Employee>
<Employee EmployeeID="2" Name="Karen">
<Properties>
<Property EmployeeID="2" PropertyID="1" Value="weight">
</Property>
</Properties>
</Employee>
</Employees>
(It is just an example, so don't pay attention to the contents only the structure).
As you can see each "Employee" object has a group of sub-objects of the type "Property". What I am trying to do is to insert all this data (the collection) in one go to the database. But the table Employee has a column EmployeeID which is an identity column (I don't insert the coming EmployeeIDs, they are generated automatically). So the question is - how to insert both Employees and their Properties with the correct ID references.
Any ideas?
I have a problem here with the SQL query. I get a parameter @xmlObject of ntext type which contains the data objects in xml format. Like this:
<Employees>
<Employee EmployeeID="1" Name="John">
<Properties>
<Property EmployeeID="1" PropertyID="1" Value="age">
</Property>
<Property EmployeeID="1" PropertyID="2" Value="height">
</Property>
</Properties>
</Employee>
<Employee EmployeeID="2" Name="Karen">
<Properties>
<Property EmployeeID="2" PropertyID="1" Value="weight">
</Property>
</Properties>
</Employee>
</Employees>
(It is just an example, so don't pay attention to the contents only the structure).
As you can see each "Employee" object has a group of sub-objects of the type "Property". What I am trying to do is to insert all this data (the collection) in one go to the database. But the table Employee has a column EmployeeID which is an identity column (I don't insert the coming EmployeeIDs, they are generated automatically). So the question is - how to insert both Employees and their Properties with the correct ID references.
Any ideas?