Can't get XSD to generate DataSet primary keys - CSharp
This is a discussion on Can't get XSD to generate DataSet primary keys - CSharp ; [.Net 2.0, VS2005 SP1, MSDataSetGenerator used through IDE]
No matter how I shape my XSD, I can't get it to create primary keys in my
data set. I have looked at tons of examples, followed them to the letter,
but ...
-
Can't get XSD to generate DataSet primary keys
[.Net 2.0, VS2005 SP1, MSDataSetGenerator used through IDE]
No matter how I shape my XSD, I can't get it to create primary keys in my
data set. I have looked at tons of examples, followed them to the letter,
but still no go. When I merge my data sets I get duplicate records. If I go
in and add the PrimaryKey to the DataSet based classes that were generated
by the tool everything works. I just can't get the tool to create them. Help
Please.
(One thing I did notice that was weird was that in VisualStudio intellisense
was available for msdata:whatever, all the attributes I saw in the examples
were available except msdata:PrimaryKey).
Anyway here is my XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="SensorDataSet">
<xs:element name="Type" type="xs:string" />
<xs:element name="Timestamp" type="xs:string" />
<xs:element name="Start" type="xs:decimal" />
<xs:element name="Speed" type="xs:byte" />
<xs:element name="OrderNumber" type="xs:short" />
<xs:element name="NameDescription" type="xs:string" />
<xs:element name="Name" type="xs:string" />
<xs:element name="Longitude" type="xs:decimal" />
<xs:element name="Latitude" type="xs:decimal" />
<xs:element name="ItsRoadwayDescription" type="xs:string" />
<xs:element name="Id" type="xs:string" />
<xs:element name="Description" type="xs:string" />
<xs:element name="Sensor">
<xs:complexType>
<xs:sequence>
<xs:element ref="Type" />
<xs:element ref="OrderNumber" />
<xs:element ref="Id" />
<xs:element ref="Description" />
<xs:element ref="ItsRoadwayDescription" />
<xs:element ref="Latitude" />
<xs:element ref="Longitude" />
<xs:element ref="Speed" />
<xs:element ref="RouteId" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="RouteId" type="xs:string" />
<xs:element name="Route">
<xs:complexType>
<xs:sequence>
<xs:element ref="Id" />
<xs:element ref="Name" />
<xs:element ref="Description" />
<xs:element ref="NameDescription" />
<xs:element ref="Start" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SensorFeed">
<xs:complexType>
<xs:sequence>
<xs:element ref="Sensor" maxOccurs="unbounded" />
<xs:element ref="Route" maxOccurs="unbounded" />
<xs:element ref="Timestamp" minOccurs="1"
maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:key name="SensorPrimaryKey" msdata:PrimaryKey="true"
msdata:ConstraintName="SensorPrimaryKey">
<xs:selector xpath=".//Sensor" />
<xs:field xpath="Id" />
</xs:key>
<xs:key name="RoutePrimaryKey" msdata:PrimaryKey="true"
msdata:ConstraintName="RoutePrimaryKey">
<xs:selector xpath=".//Route" />
<xs:field xpath="Id" />
</xs:key>
<xs:keyref name="SensorRouteForeignKey" refer="RoutePrimaryKey">
<xs:selector xpath=".//Sensor" />
<xs:field xpath="RouteId" />
</xs:keyref>
</xs:element>
</xs:schema>
Thanks
--
Howard Swope [hswope.swopeATnavteqDOTcom]
Senior Software Developer
Media Development
Navteq Traffic [http://www.traffic.com]
-
Re: Can't get XSD to generate DataSet primary keys
I just got fed up and simplified the .xsd as much as possible, I inlined all
the refs, and then it generated the primary keys. Yeah...
"Howard Swope" <hswopeATtrafficDOTcom> wrote in message
news:%23Gqn7pGKIHA.3672@TK2MSFTNGP02.phx.gbl...
> [.Net 2.0, VS2005 SP1, MSDataSetGenerator used through IDE]
>
> No matter how I shape my XSD, I can't get it to create primary keys in my
> data set. I have looked at tons of examples, followed them to the letter,
> but still no go. When I merge my data sets I get duplicate records. If I
> go in and add the PrimaryKey to the DataSet based classes that were
> generated by the tool everything works. I just can't get the tool to
> create them. Help Please.
>
> (One thing I did notice that was weird was that in VisualStudio
> intellisense was available for msdata:whatever, all the attributes I saw
> in the examples were available except msdata:PrimaryKey).
>
> Anyway here is my XSD
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="SensorDataSet">
>
> <xs:element name="Type" type="xs:string" />
>
> <xs:element name="Timestamp" type="xs:string" />
>
> <xs:element name="Start" type="xs:decimal" />
>
> <xs:element name="Speed" type="xs:byte" />
>
> <xs:element name="OrderNumber" type="xs:short" />
>
> <xs:element name="NameDescription" type="xs:string" />
>
> <xs:element name="Name" type="xs:string" />
>
> <xs:element name="Longitude" type="xs:decimal" />
>
> <xs:element name="Latitude" type="xs:decimal" />
>
> <xs:element name="ItsRoadwayDescription" type="xs:string" />
>
> <xs:element name="Id" type="xs:string" />
>
> <xs:element name="Description" type="xs:string" />
>
> <xs:element name="Sensor">
>
> <xs:complexType>
>
> <xs:sequence>
>
> <xs:element ref="Type" />
>
> <xs:element ref="OrderNumber" />
>
> <xs:element ref="Id" />
>
> <xs:element ref="Description" />
>
> <xs:element ref="ItsRoadwayDescription" />
>
> <xs:element ref="Latitude" />
>
> <xs:element ref="Longitude" />
>
> <xs:element ref="Speed" />
>
> <xs:element ref="RouteId" />
>
> </xs:sequence>
>
> </xs:complexType>
>
> </xs:element>
>
> <xs:element name="RouteId" type="xs:string" />
>
> <xs:element name="Route">
>
> <xs:complexType>
>
> <xs:sequence>
>
> <xs:element ref="Id" />
>
> <xs:element ref="Name" />
>
> <xs:element ref="Description" />
>
> <xs:element ref="NameDescription" />
>
> <xs:element ref="Start" />
>
> </xs:sequence>
>
> </xs:complexType>
>
> </xs:element>
>
> <xs:element name="SensorFeed">
>
> <xs:complexType>
>
> <xs:sequence>
>
> <xs:element ref="Sensor" maxOccurs="unbounded" />
>
> <xs:element ref="Route" maxOccurs="unbounded" />
>
> <xs:element ref="Timestamp" minOccurs="1"
> maxOccurs="1" />
>
> </xs:sequence>
>
> </xs:complexType>
>
> <xs:key name="SensorPrimaryKey" msdata:PrimaryKey="true"
> msdata:ConstraintName="SensorPrimaryKey">
>
> <xs:selector xpath=".//Sensor" />
>
> <xs:field xpath="Id" />
>
> </xs:key>
>
> <xs:key name="RoutePrimaryKey" msdata:PrimaryKey="true"
> msdata:ConstraintName="RoutePrimaryKey">
>
> <xs:selector xpath=".//Route" />
>
> <xs:field xpath="Id" />
>
> </xs:key>
>
> <xs:keyref name="SensorRouteForeignKey"
> refer="RoutePrimaryKey">
>
> <xs:selector xpath=".//Sensor" />
>
> <xs:field xpath="RouteId" />
>
> </xs:keyref>
>
> </xs:element>
>
> </xs:schema>
>
>
>
> Thanks
> --
> Howard Swope [hswope.swopeATnavteqDOTcom]
> Senior Software Developer
> Media Development
> Navteq Traffic [http://www.traffic.com]
>
Similar Threads
-
By Application Development in forum ADO DAO RDO RDS
Replies: 4
Last Post: 10-11-2007, 05:28 PM
-
By Application Development in forum ADO DAO RDO RDS
Replies: 0
Last Post: 08-16-2007, 07:53 PM
-
By Application Development in forum Java
Replies: 1
Last Post: 03-01-2007, 09:39 AM
-
By Application Development in forum Java
Replies: 1
Last Post: 08-05-2005, 01:20 PM
-
By Application Development in forum ADO DAO RDO RDS
Replies: 0
Last Post: 07-29-2004, 08:54 AM