Ejemplo n.º 1
0
        /// <summary>
        /// Get a DmRow by its primary key (composed by a multi columns key)
        /// </summary>
        public DmRow FindByKey(object[] key)
        {
            if (!primaryKey.HasValue)
            {
                return(null);
            }

            return(this.Rows.FirstOrDefault(r => primaryKey.ValuesAreEqual(r, key)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the parent rows for the given child row across the relation using the version given
        /// </summary>
        internal static DmRow[] GetParentRows(DmKey parentKey, DmKey childKey, DmRow childRow, DmRowVersion version)
        {
            object[] values = childRow.GetKeyValues(childKey, version);
            if (IsKeyNull(values))
            {
                return new DmRow[] { parentKey.Table.NewRow() }
            }
            ;

            return(parentKey.Table.Rows.Where(r => parentKey.ValuesAreEqual(r, values)).ToArray());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// For a foreignkey, actually we have only one row
        /// </summary>
        internal static DmRow GetParentRow(DmKey parentKey, DmKey childKey, DmRow childRow, DmRowVersion version)
        {
            if (!childRow.HasVersion((version == DmRowVersion.Original) ? DmRowVersion.Original : DmRowVersion.Current))
            {
                if (childRow.tempRecord == -1)
                {
                    return(null);
                }
            }

            object[] values = childRow.GetKeyValues(childKey, version);
            if (IsKeyNull(values))
            {
                return(null);
            }

            return(parentKey.Table.Rows.FirstOrDefault(r => parentKey.ValuesAreEqual(r, values)));
        }