I really think what I'm trying to accomplish should be fairly easy, however I can't seem to find any good information that addresses how to solve this.
Basically, I'm trying to create NHibernate mapping for some simple classes that have been driven via XSD. For example, here's the simple class structure that I'm trying to map:
Code:
namespace com.test.schema {
using System.Xml.Serialization;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:com.test.schema")]
[System.Xml.Serialization.XmlRootAttribute("User", Namespace="urn:com.test.schema", IsNullable=false)]
public partial class UserType {
private int userIdField;
private string userNameField;
private string nameField;
private string emailField;
private AliasType[] aliasField;
/// <remarks/>
public int UserId {
get {
return this.userIdField;
}
set {
this.userIdField = value;
}
}
/// <remarks/>
public string UserName {
get {
return this.userNameField;
}
set {
this.userNameField = value;
}
}
/// <remarks/>
public string Name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
/// <remarks/>
public string Email {
get {
return this.emailField;
}
set {
this.emailField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Alias")]
public AliasType[] Alias {
get {
return this.aliasField;
}
set {
this.aliasField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:com.test.schema")]
public partial class AliasType {
private string typeField;
private string firstField;
private string middleField;
private string lastField;
/// <remarks/>
public string Type {
get {
return this.typeField;
}
set {
this.typeField = value;
}
}
/// <remarks/>
public string First {
get {
return this.firstField;
}
set {
this.firstField = value;
}
}
/// <remarks/>
public string Middle {
get {
return this.middleField;
}
set {
this.middleField = value;
}
}
/// <remarks/>
public string Last {
get {
return this.lastField;
}
set {
this.lastField = value;
}
}
}
}
As you can see, I have a simple one-to-many relationship between User and Alias. What is the best way to map these structures and what columns do I need in my database schema? I assume that I'll need additional "keys" to maintain the relationship.
Sorry if this is a basic question and I'm just missing something.