/// <summary> /// Checks that the column names specified in the configuration, consolidation /// section are valid for the given entity /// </summary> public static void CheckNaturalKeyColumnsInConfiguration(ConsolidationParams consolidationParams) { _log.Debug("Checking that consolidation key columns are valid in configuration"); StagingTablesBuilder b = StagingTablesBuilder.Get(StagingSchema.PrimaryStagingSchemaName); if (consolidationParams.Enabled) { var entitiesUsed = new List <Entity>(); foreach (Entity entity in Enum.GetValues(typeof(Entity))) { if (EntityUtils.CanParticipateInConsolidation(entity)) { if (entitiesUsed.Contains(entity)) { throw new ApplicationException(string.Format("Entity declared more than once in consolidation configuration: {0}", entity)); } entitiesUsed.Add(entity); var entry = consolidationParams.Get(entity); if (entry != null && !entry.None) { string stagingTableName = EntityUtils.ToCtTableName(entity); var table = b.GetTable(stagingTableName); if (!table.ColumnExists(entry.Column)) { throw new ApplicationException(string.Format("The specified consolidation column ({0}) does not exist in the entity: {1}", entry.Column, entity)); } } } } } }