- ROP_IDE.zip
- Clifton.Collections.Generic
- Clifton.Data
- Clifton.Services
- Clifton.Tools.Data
- Clifton.Tools.Strings
- Clifton.Windows.Forms
- DataSetDataProvider
- IDE
- Interfaces.UI
- Myxaml 2.0
- MyXaml.Core
- MyXaml.WinForms
- ROPLib.Data
- ROPLib.Graphing
- ROPLib.Interfaces
- ROPLib.RendererInterfaces
- ROPLib.Reporting
- ROPLib.UIEvents
- ROPLib.UIRendering
- ROPLib
- SQLLiteDataProvider
- UI.DotNet
- UI.DX
- UnitTest
- XTreeInterfaces
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Clifton.Tools.Strings;
using Clifton.Tools.Strings.Extensions;
using XTreeInterfaces;
namespace ROPLib
{
public enum CardinalityEnum
{
OneToZeroOrOne, // A can have 0 or 1 connections to B.
OneToOne, // requires a B.
OneToMany, // A can have 0...n connections to B.
ManyToOne, // B can have 1...n connections th A.
ManyToMany, // An association table is required to describe the relationship.
ManyToZeroOrOne, // Nullable FK.
}
public class Relationship : IHasCollection
{
[Category("Name")]
[XmlAttribute()]
public string Name { get; set; }
/// <summary>
/// The name of the "A" Entity
/// </summary>
[Category("Entities")]
[TypeConverter(typeof(EntityNameConverter))]
public string EntityA { get; set; }
/// <summary>
/// The name of the "B" Entity
/// </summary>
[Category("Entities")]
[TypeConverter(typeof(EntityNameConverter))]
public string EntityB { get; set; }
/// <summary>
/// The cardinality of the relationship of A to B
/// </summary>
[Category("Cardinality")]
public CardinalityEnum AtoBCardinality { get; set; }
/// <summary>
/// The text describing the A to B relationship
/// </summary>
[Category("Relationship")]
[Description("The text used to describe the A to B relationship.")]
public string AtoBRelationship { get; set; }
/// <summary>
/// The text describing the B to A relationship
/// </summary>
[Category("Relationship")]
[Description("The text used to describe the B to A relationship.")]
public string BtoARelationship { get; set; }
[Category("Attributes")]
[TypeConverter(typeof(EntityNameConverter))]
[Description("The relationship itself can have attributes that are described by an Entity.")]
[XmlAttribute()]
public string DescribedWith { get; set; }
[Category("Schema")]
[Description("The attribute in Entity A that is the foreign key to a primary key attribute in Entity B.")]
[XmlAttribute()]
[TypeConverter(typeof(EntityAttributesConverter))]
public string ForeignKeyAttribute { get; set; }
[XmlIgnore]
[Browsable(false)]
public Dictionary<string, dynamic> Collection { get; protected set; }
[Browsable(false)]
public List<RelationshipTypes> RelationshipTypes { get; set; }
[Browsable(false)]
public string Label { get { return Name.Brace() + "\\n" + AtoBRelationship + " /\\n" + BtoARelationship; } }
[Browsable(false)]
public string CardinalityALabel { get { return CardinalityALabels[(int)AtoBCardinality]; } }
[Browsable(false)]
public string CardinalityBLabel { get { return CardinalityBLabels[(int)AtoBCardinality]; } }
protected string[] CardinalityALabels = { "1", "1", "1", "n", "m", "n" };
protected string[] CardinalityBLabels = { "0,1", "1", "n", "1", "n", "0,1" };
public Relationship()
{
DescribedWith = String.Empty;
ForeignKeyAttribute = String.Empty;
RelationshipTypes = new List<RelationshipTypes>();
Collection = new Dictionary<string, dynamic>() {
{"RelationshipTypes", RelationshipTypes},
};
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.