/// <summary> /// Returns collection of dependent entites. /// </summary> /// <returns>Collection of dependent entites.</returns> protected virtual Dictionary <string, List <Guid> > GetDependentEntities() { EntitySchema entity = EntitySchemaManager.GetInstanceByName(EntitySchemaName); EntitySchemaOppositeReferenceInfoCollection dependentEntites = EntitySchemaManager.GetSchemaOppositeReferences(entity.UId, EntitySchemaColumnUsageType.General, UserConnection, true); var result = new Dictionary <string, List <Guid> >(); foreach (EntitySchemaOppositeReferenceInfo dependentEntity in dependentEntites) { EntitySchema depEntity = EntitySchemaManager.GetInstanceByName(dependentEntity.SchemaName); if (!depEntity.IsDBView) { AddDependentEntity(dependentEntity, result); } } return(result); }
private void MergeDetailRecordsByRule(string mergeRule, string detailName, Guid goldRecordId, List <Guid> duplicateRecordIds, DBExecutor dbExecutor, EntitySchemaOppositeReferenceInfoCollection schemaReferences) { if (mergeRule.StartsWith(MergeRuleStoredProcedurePrefix)) { string duplicateRecordIdsToString = string.Join("", duplicateRecordIds.ToArray()); var storedProcedure = new StoredProcedure(UserConnection, mergeRule); storedProcedure.WithParameter("GoldenRecordId", goldRecordId); storedProcedure.WithParameter("DuplicateList", duplicateRecordIdsToString); storedProcedure.Execute(dbExecutor); return; } var detailSchema = UserConnection.EntitySchemaManager.GetInstanceByName(detailName); if (UserConnection.GetIsFeatureEnabled("FetchSchemaFromMetadataForDeduplication")) { var columnUids = schemaReferences.Where(referenceInfo => referenceInfo.SchemaUId == detailSchema.UId && referenceInfo.ColumnUId != null) .Select(x => x.ColumnUId); foreach (var columnUid in columnUids) { var entityColumn = detailSchema.Columns.FindByUId(columnUid); if (entityColumn == null) { continue; } var entityColumnAlias = entityColumn.ColumnValueName; var ruleColumns = GetRuleColumns(mergeRule, entityColumnAlias); MergeByRule(ruleColumns, detailName, entityColumn.ColumnValueName, dbExecutor, goldRecordId, duplicateRecordIds); } } else { (var ruleEntityColumn, var aggregationColumns) = ParseRuleBody(mergeRule); MergeByRule(aggregationColumns, detailName, ruleEntityColumn, dbExecutor, goldRecordId, duplicateRecordIds); } }