Example #1
0
        protected override void DoRun(Record record)
        {
            List <string> primaryKeyValues = new List <string>();

            foreach (Field field in record.Fields)
            {
                if (field.Definition.IsPartOfPrimaryKey())
                {
                    primaryKeyValues.Add(field.Value);
                }
            }
            PrimaryKeyValue primaryKeyValueForCurrentRecord = new PrimaryKeyValue(primaryKeyValues);

            RecordIndex recordIndex = record.Definition.GetIndex();

            if (!_primaryKeyValuesPerRecord.ContainsKey(recordIndex))
            {
                _primaryKeyValuesPerRecord.Add(recordIndex, new HashSet <PrimaryKeyValue>());
            }
            HashSet <PrimaryKeyValue> allPrimaryKeyValuesForRecord = _primaryKeyValuesPerRecord[recordIndex];

            // If null, this primary key value is already handled
            if (allPrimaryKeyValuesForRecord == null)
            {
                return;
            }

            // If list of primary key values already contains the value, it is not unique
            if (allPrimaryKeyValuesForRecord.Contains(primaryKeyValueForCurrentRecord))
            {
                if (!_nonUniqueprimaryKeyValuesPerRecord.ContainsKey(recordIndex))
                {
                    _nonUniqueprimaryKeyValuesPerRecord.Add(recordIndex, new HashSet <PrimaryKeyValue>());
                }
                _nonUniqueprimaryKeyValuesPerRecord[recordIndex].Add(primaryKeyValueForCurrentRecord);

                _primaryKeyValuesPerRecord[recordIndex].Remove(primaryKeyValueForCurrentRecord);
            }
            else
            {
                allPrimaryKeyValuesForRecord.Add(primaryKeyValueForCurrentRecord);
            }
        }
Example #2
0
 protected bool Equals(PrimaryKeyValue other)
 {
     return(_primaryKeyValues.SequenceEqual(other._primaryKeyValues));
 }