Ejemplo n.º 1
0
        /// <summary>
        /// Verify if the insert operation can be performed.
        /// </summary>
        /// <param name="row"></param>
        internal void CheckInsert(object[] row)
        {
            if (_type == ConstraintType.Main || _type == ConstraintType.Unique)
            {
                // inserts in the main table are never a problem
                // unique constraints are checked by the unique index
                return;
            }

            // must be called synchronized because of _mainData
            for (int i = 0; i < _len; i++)
            {
                object o = row[_refColumns[i]];

                if (o == null)
                {
                    // if one column is null then integrity is not checked
                    return;
                }

                _mainData[_mainColumns[i]] = o;
            }

            // a record must exist in the main table
            Trace.Check(_mainIndex.Find(_mainData) != null,
                        Trace.INTEGRITY_CONSTRAINT_VIOLATION);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify if the delete operation can be performed.
        /// </summary>
        /// <param name="row"></param>
        internal void CheckDelete(object[] row)
        {
            if (_type == ConstraintType.ForeignKey || _type == ConstraintType.Unique)
            {
                // deleting references are never a problem
                // unique constraints are checked by the unique index
                return;
            }

            // must be called synchronized because of _refData
            for (int i = 0; i < _len; i++)
            {
                object o = row[_mainColumns[i]];

                if (o == null)
                {
                    // if one column is null then integrity is not checked
                    return;
                }

                _refData[_refColumns[i]] = o;
            }

            // there must be no record in the 'slave' table
            Trace.Check(_refIndex.Find(_refData) == null,
                        Trace.INTEGRITY_CONSTRAINT_VIOLATION);
        }