Optional, Multi-Column DataSet Relationships
Perhaps I'm a moron and everybody else in the .NET development community knew this before I did. But I will confess that until today, I had no idea how to create optional, multi-column relationships in strongly typed data sets. I knew that you can use the <xs:keyref> element to create multi-column relationships, but these relationships come with foreign keys, making them required. I also knew that you could use the <msdata:Relationship> annotation to create relationships without requiring foreign keys, but up until today, I thought you could only specify a single column in each of the msdata:parentkey and msdata:childkey attributes. Well, it turns out I was wrong. After reflecting deep into the data set code generator, I found that you can specify a space-delimited or plus-delimited list of columns in each of these attributes to create a multi-column relationship. So, the following is a perfectly valid element in an XSD schema used to generate a strongly-typed DataSet:
<xs:annotation>
<xs:appinfo>
<msdata:Relationship
name="SurplusLetter_SurplusWarrant"
msdata:parent="SurplusWarrant"
msdata:child="SurplusLetter"
msdata:parentkey="SurplusAccountID WarrantID"
msdata:childkey="ResultingWarrantAccountID ResultingWarrantID" />
</xs:appinfo>
</xs:annotation>
I have scoured the web searching for any documentation of the msdata:Relationship annotation, and I have never found any mention of this feature. So hopefully I can save you the headaches that I had to put up with until I stumbled on this.