コード例 #1
0
        public DmRelation AddForeignKey(string relationName, DmColumn childColumn, DmColumn parentColumn)
        {
            // check if child column is from the current table
            if (!this.Columns.Contains(childColumn))
            {
                throw new Exception("Child column should belong to the dmTable");
            }


            DmRelation dr = new DmRelation(relationName, parentColumn, childColumn);

            this.DmSet.Relations.Add(dr);

            return(dr);
        }
コード例 #2
0
        public DmRelation AddForeignKey(DmRelation relation)
        {
            // check if child column is from the current table
            foreach (var c in relation.ChildColumns)
            {
                if (!this.Columns.Contains(c))
                {
                    throw new Exception("Child column should belong to the dmTable");
                }
            }

            this.DmSet.Relations.Add(relation);

            return(relation);
        }
コード例 #3
0
        internal DmRelation Clone(DmSet destination)
        {
            DmTable parent    = destination.Tables[ParentTable.TableName];
            DmTable child     = destination.Tables[ChildTable.TableName];
            int     keyLength = parentKey.Columns.Length;

            DmColumn[] parentColumns = new DmColumn[keyLength];
            DmColumn[] childColumns  = new DmColumn[keyLength];

            for (int i = 0; i < keyLength; i++)
            {
                parentColumns[i] = parent.Columns[ParentKey.Columns[i].ColumnName];
                childColumns[i]  = child.Columns[ChildKey.Columns[i].ColumnName];
            }

            DmRelation clone = new DmRelation(RelationName, parentColumns, childColumns);

            return(clone);
        }
コード例 #4
0
        /// <summary>
        /// Gets the parent row of this <see cref='System.Data.DataRow'/>
        /// using the specified <see cref='System.Data.DataRelation'/> and <see cref='System.Data.DataRowVersion'/>.
        /// </summary>
        public DmRow GetParentRow(DmRelation relation, DmRowVersion version)
        {
            if (relation == null)
            {
                return(null);
            }

            if (relation.DmSet != table.DmSet)
            {
                throw new Exception("RowNotInTheDataSet");
            }

            if (relation.ChildKey.Table != table)
            {
                throw new Exception("RelationForeignTable");
            }


            return(DmRelation.GetParentRow(relation.ParentKey, relation.ChildKey, this, version));
        }
コード例 #5
0
        public virtual DmSet Clone()
        {
            DmSet ds = new DmSet();

            ds.DmSetName     = this.DmSetName;
            ds.CaseSensitive = this.CaseSensitive;
            ds.Culture       = this.Culture;

            for (int i = 0; i < Tables.Count; i++)
            {
                DmTable dt = Tables[i].Clone();
                ds.Tables.Add(dt);
            }

            List <DmRelation> rels = Relations;

            for (int i = 0; i < rels.Count; i++)
            {
                DmRelation rel = rels[i].Clone(ds);
                ds.Relations.Add(rel);
            }

            return(ds);
        }
コード例 #6
0
 /// <summary>
 /// Gets the parent rows of this DmRow using the specified DmRelation .
 /// </summary>
 public DmRow[] GetParentRows(DmRelation relation) =>
 GetParentRows(relation, DmRowVersion.Default);
コード例 #7
0
 /// <summary>
 /// Gets the child rows of this DmRow using the
 /// specified DmRelation.
 /// </summary>
 public DmRow[] GetChildRows(DmRelation relation) =>
 GetChildRows(relation, DmRowVersion.Default);