Class Relation
Represents a relation between two dimensions.
Implements
Inherited Members
Namespace: TimeCockpit.Data.DataModel
Assembly: TimeCockpit.Data.dll
Syntax
public class Relation : RelationBase, IDynamicMetaObjectProvider, INotifyPropertyChanged, IDataErrorInfo, INullable
Constructors
Relation()
Initializes a new instance of the Relation class
Declaration
public Relation()
Relation(IEnumerable<KeyValuePair<Object, Object>>)
Initializes a new instance of the Relation class.
Declaration
public Relation(IEnumerable<KeyValuePair<object, object>> properties)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Object, System.Object>> | properties | Collection of properties. |
Remarks
You can use this constructor to initialize a new instance of the ModelRelation class by specifying its properties in a list of key/value pairs. This is especially useful for dynamic languages like python.
Relation(Relation)
Initializes a new instance of the Relation class
Declaration
public Relation(Relation element)
Parameters
| Type | Name | Description |
|---|---|---|
| Relation | element | The relation to copy. |
Remarks
This copy constructor creates copies of all value-typed properties. StorageColumns and Permissions from element are just added to the corresponding collections of the new Relation. No copying is performed.
Properties
BackReferenceInvariantFriendlyName
Gets or sets the name of the back reference invariant friendly.
Declaration
public string BackReferenceInvariantFriendlyName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | The name of the back reference invariant friendly. |
BackReferenceName
Gets or sets the name of the back reference for the relation.
Declaration
public string BackReferenceName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
In a 1:n relation the relation's name can be used to identify the
related object on the left side of the relation (e.g. given a 1:n relationship
CustomerRelation between customers and project its name can be used on a
Project entity to identify the related Customer entity:
Project.CustomerRelation).
The back reference name can be used to identify the list of entities
on the right side of the relation (e.g. Customer.Projects can be used
to identify all projects for a customer entity if Projects is the
BackReferenceName of the relation).
You have to set the back reference name explicitly. If you do not set it you cannot use functions depending on back reference names (e.g. subqueries).
DefaultValueExpression
Gets or sets the expression that determines the default value of the property
Declaration
public string DefaultValueExpression { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DefaultValueFunction
Gets the default value of a property by evaluate an expression
Declaration
public Func<EntityObject, Environment, IEnumerable<QueryParameter>, object> DefaultValueFunction { get; }
Property Value
| Type | Description |
|---|---|
| System.Func<EntityObject, Environment, System.Collections.Generic.IEnumerable<QueryParameter>, System.Object> |
EvaluateDefaultValue
Gets a value indicating whether to evaluate the default value.
Declaration
public bool EvaluateDefaultValue { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
EvaluateDefaultValueExpression
Gets or sets the default value evaluation time expression.
Declaration
public string EvaluateDefaultValueExpression { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | The default value evaluation time expression. |
EvaluateDefaultValueFunction
Gets a value determining whether a default value should be evaluated
Declaration
public Func<EntityObject, bool> EvaluateDefaultValueFunction { get; }
Property Value
| Type | Description |
|---|---|
| System.Func<EntityObject, System.Boolean> |
HasDefaultValueExpression
Gets a value indicating whether a property has a default value expression or not
Declaration
public bool HasDefaultValueExpression { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsNullable
Gets or sets a value indicating whether the Relation instance should be nullable or not.
Declaration
public override bool IsNullable { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
Overrides
OnDeleteAction
Gets or sets the on delete action.
Declaration
public OnDeleteAction OnDeleteAction { get; set; }
Property Value
| Type | Description |
|---|---|
| OnDeleteAction |
StorageColumns
Gets a list of storage columns.
Declaration
public virtual Collection<StorageColumn> StorageColumns { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.ObjectModel.Collection<StorageColumn> | List of storage columns. |
Target
Gets or sets the target of the relation.
Declaration
public override ModelEntityBase Target { get; set; }
Property Value
| Type | Description |
|---|---|
| ModelEntityBase |
Overrides
Methods
Accept(ModelElementVisitor)
Accepts a visitor. Dispatches the correct call in the visitor.
Declaration
public override void Accept(ModelElementVisitor visitor)
Parameters
| Type | Name | Description |
|---|---|---|
| ModelElementVisitor | visitor | the visitor to accept. |
Overrides
InitializeObject()
Initializes the Relation object setting fields of the object to their default values.
Declaration
protected override void InitializeObject()
Overrides
IsValueAffectedByPropertyChange(EntityObject, String)
Determines whether the value for this property is changed if the memberName is changed.
Declaration
public bool IsValueAffectedByPropertyChange(EntityObject entityObject, string memberName)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | entityObject | The entityobject holding the property that changed. |
| System.String | memberName | The name of the member (relation or property) that changed. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the value of a property is affected by a changed property name. |
OnDeserializing(StreamingContext)
Called whenever deserialization of the model element is happening
Declaration
[OnDeserializing]
public void OnDeserializing(StreamingContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Runtime.Serialization.StreamingContext | context | Stream context used for deserialization. |
Remarks
This method is necessary to instantiate an instance of the current ModelElement after deserialization. As for the System.Runtime.Serialization.DataContractSerializer, constructors are not always called and fields not correctly initialized. While deserializing, this method is called and the fields of the ModelElement are correctly initialized.
ShallowCopy()
Performs a shallow copy of the current Relation.
Declaration
public override RelationBase ShallowCopy()
Returns
| Type | Description |
|---|---|
| RelationBase | A shallow copy of the current Relation. |
Overrides
Remarks
The MemberwiseClone method creates a shallow copy by creating a new object, and then copying the nonstatic fields of the current object to the new object. If a field is a value type, a bit-by-bit copy of the field is performed. If a field is a reference type, the reference is copied but the referred object is not; therefore, the original object and its clone refer to the same object.
ShallowCopy(String, PersistBehavior, Ownership, Boolean, Boolean)
Performs a shallow copy of the current Relation.
Declaration
public override RelationBase ShallowCopy(string name, PersistBehavior persistBehavior, Ownership ownership, bool ignorePermissions = false, bool ignoreDefaultValues = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the property to clone. |
| PersistBehavior | persistBehavior | The PersistBehavior the cloned relation should have. |
| Ownership | ownership | The Ownership the cloned relation should have. |
| System.Boolean | ignorePermissions | if set to |
| System.Boolean | ignoreDefaultValues | if set to |
Returns
| Type | Description |
|---|---|
| RelationBase | A shallow copy of the current Relation. |
Overrides
Remarks
The MemberwiseClone method creates a shallow copy by creating a new object, and then copying the nonstatic fields of the current object to the new object. If a field is a value type, a bit-by-bit copy of the field is performed. If a field is a reference type, the reference is copied but the referred object is not; therefore, the original object and its clone refer to the same object.
Validate(ref IList<PropertyValidationMessage>, Boolean)
Validates a ModelElement according to certain rules.
Declaration
protected override void Validate(ref IList<PropertyValidationMessage> messages, bool validateRecursively)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IList<PropertyValidationMessage> | messages | An list of strings that stores that picks up the validation errors of a model element. |
| System.Boolean | validateRecursively | Indicates wheter to validate only the current model element or all its children (recursively) as well. |
Overrides
Remarks
The rules the ModelElement is validated against are dependent on the type of ModelElement that is validated. This method can be overridden to provide custom validation behavior for subclasses of ModelElement
When Validate(ref IList<PropertyValidationMessage>, Boolean) is called on a modelelement, the Validate(ref IList<PropertyValidationMessage>, Boolean) method of all children attatched to the modelelemnt are validated recursivly.