RelationAttribute

Overview

This attribute is used by DA LINQ to define the field property as a foreign key of the detail table.

For example, in this relationship, Customers is the master table and Orders is the child table, where 'CustomerId' is the foreign key in Orders.

The folowing code will be generated for the field Orders.CustomerId:

    [RemObjects.DataAbstract.Linq.TableName("Orders")]
    public partial class Orders : System.ICloneable, 
          System.ComponentModel.INotifyPropertyChanged, 
          System.ComponentModel.INotifyPropertyChanging {

        ...

        [RemObjects.DataAbstract.Linq.Relation("Customers", "Id")]
        [RemObjects.DataAbstract.Linq.FieldName("CustomerId")]
        [RemObjects.DataAbstract.Linq.DataType(RemObjects.DataAbstract.Schema.DataType.WideString)]
        [RemObjects.DataAbstract.Linq.LogChanges()]
        public virtual string CustomerId {
            get {
                return f____CustomerId;
            }
            set {
                if ((System.Collections.Generic.Comparer<string>.Default.Compare(this.f____CustomerId, value) != 0)) {
                    this.m____TriggerPropertyChanging("CustomerId");
                    f____CustomerId = value;
                    this.m____TriggerPropertyChanged("CustomerId");
                }
            }
        }
    
    ...

Here, the Relation attibute indicates that this field is the foreign key in the Orders table and is related to the Customers table with the 'Id' primary key.

Location

Properties


RelationFieldName

Primary key of the RelationTableName table, related to the context data table.

 

property RelationFieldName: String read;

 

String RelationFieldName { get; }

 

ReadOnly Property RelationFieldName() As String

RelationTableName

Name of the related master table.

 

property RelationTableName: String read;

 

String RelationTableName { get; }

 

ReadOnly Property RelationTableName() As String

Instance Methods


constructor

Creates a new instance of the RelationAttribute with an initialization of the inner fields.

 

constructor(table: String; field: String)

 

RelationAttribute(String table, String field)

 

Sub New(table As String, field As String)

Parameters:

  • table: Name of the Schema table that contains the related RelationFieldName Schema field
  • field: Name of the Schema field contained in the table Schema table