public RelationshipModel(string name, EndModel principalEnd, EndModel dependentEnd) { this._name = name; this._principalEnd = principalEnd; this._principalEnd.Relationship = this; this._dependentEnd = dependentEnd; this._dependentEnd.Relationship = this; this.UpdateCascade = true; this.DeleteCascade = true; }
public void ReadXml(System.Xml.XmlReader reader) { // Attributes while (reader.MoveToNextAttribute()) { switch (reader.Name) { case XmlAttribute_Name: this.Name = reader.Value; break; case XmlAttribute_UpdateCascade: this.UpdateCascade = Convert.ToBoolean(reader.Value); break; case XmlAttribute_DeleteCascade: this.DeleteCascade = Convert.ToBoolean(reader.Value); break; } } reader.MoveToContent(); // Element if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.NodeType == System.Xml.XmlNodeType.Element) { switch (reader.Name) { case EndModel.XmlElement_Principal: this._principalEnd = new EndModel(); this._principalEnd.ReadXml(reader); break; case EndModel.XmlElement_Dependent: this._dependentEnd = new EndModel(); this._dependentEnd.ReadXml(reader); break; default: throw new InvalidOperationException(reader.Name); } } reader.ReadEndElement(); } else { reader.Read(); } }
public RelationshipModel(EndModel principalEnd, EndModel dependentEnd) : this("FK" + DatabaseHelper.Relation + principalEnd.Table + DatabaseHelper.Relation + dependentEnd.Table, principalEnd, dependentEnd) { }