Exemplo n.º 1
0
        private int ReportUnallowedReference([NotNull] IRow row,
                                             [NotNull] Tuple fkTuple)
        {
            string description =
                string.Format(
                    "Values [{0}] in fields '{1}' references a value combination in fields '{2}' of table '{3}'{4}",
                    FormatTuple(fkTuple),
                    _foreignKeyFieldNamesString, _referencedKeyFieldNamesString,
                    DatasetUtils.GetName(_referencedTable),
                    StringUtils.IsNotEmpty(_whereClause)
                                                ? string.Format(" (in rows matching '{0}')", _whereClause)
                                                : string.Empty);

            return(ReportError(description,
                               Codes[Code.UnexpectedReferencedRow],
                               _foreignKeyFieldNamesString, row));
        }
Exemplo n.º 2
0
        private int VerifyTupleKey([NotNull] IRow row)
        {
            Assert.NotNull(_tupleKeySet, "tuple keyset is null");

            string errorMessage;
            Tuple  fkTuple = TryReadForeignKeyTuple(row, _foreignKeyFieldIndices,
                                                    _foreignKeyFieldTypes,
                                                    _referencedKeyFieldTypes,
                                                    _foreignKeyFields,
                                                    _referencedKeyFields,
                                                    out errorMessage);

            if (fkTuple == null)
            {
                // unable to read the tuple
                return(ReportError(errorMessage,
                                   Codes[Code.UnableToConvertFieldValue],
                                   null, row));
            }

            if (fkTuple.IsNull)
            {
                // the composite foreign key values are all null --> ok
                return(NoError);
            }

            if (_referenceIsError)
            {
                return(_tupleKeySet.Contains(fkTuple)
                                               ? ReportUnallowedReference(row, fkTuple)
                                               : NoError);
            }

            return(_tupleKeySet.Contains(fkTuple)
                                       ? NoError
                                       : ReportMissingReference(row, fkTuple));
        }
Exemplo n.º 3
0
 private static string FormatTuple([NotNull] Tuple tuple)
 {
     return(StringUtils.Concatenate(tuple.Keys, FieldValueUtils.FormatValue, ","));
 }