void IReplicationStrategy.Replicate(IReplicationArticle article)
 {
     if (article.ArticleType != DataContracts.Enums.eArticleType.TABLE)
         throw new ArgumentException("Only ArticleType = eArticleType.TABLE supported by this strategy");
     ITableSchemaAnalyzer sourceTableAnalyzer = new TableSchemaAnalyzer(_sourceConnectionString, _log, _sqlCommandFactory);
     Table sourceTable = sourceTableAnalyzer.GetTableInfo(article.SourceDatabaseName, article.SourceSchema, article.ArticleName);
     ITableSchemaAnalyzer targetTableAnalyzer = new TableSchemaAnalyzer(_targetConnectionString, _log, _sqlCommandFactory);
     Table targetTable = targetTableAnalyzer.GetTableInfo(article.TargetDatabaseName, article.TargetSchema, article.ArticleName);
     CheckReplicationPrerequisities(article, sourceTable, targetTable);
     Replicate(sourceTable, targetTable);
 }
 void CheckReplicationPrerequisities(IReplicationArticle article, Table sourceTable, Table targetTable)
 {
     //Replication strategy requires that the table contains primary key column of int data type and that the value of the column is incremented
     if (!sourceTable.Columns.Any(c => c.IsPrimaryKey &&
                               (c.DataType == System.Data.SqlDbType.TinyInt ||
                                c.DataType == System.Data.SqlDbType.SmallInt ||
                                c.DataType == System.Data.SqlDbType.Int ||
                                c.DataType == System.Data.SqlDbType.BigInt)))
     {
         if (sourceTable.Columns.SingleOrDefault(c => c.IsForeignKey &&
                                (c.DataType == System.Data.SqlDbType.TinyInt ||
                                 c.DataType == System.Data.SqlDbType.SmallInt ||
                                 c.DataType == System.Data.SqlDbType.Int ||
                                 c.DataType == System.Data.SqlDbType.BigInt)) == null)
             throw new ReplicationException($"Table {sourceTable.Name} doesn't contain primary key or single foreign key column or the type of the key column is not TinyInt or SmallInt or Int or BigInt");
     }
     IReplicationAnalyzer replicationAnalyzer = new ReplicationAnalyzer(_log);
     if (!replicationAnalyzer.AreTableSchemasReplicationCompliant(sourceTable, targetTable))
         throw new ReplicationException($"Source and target table {sourceTable.Name} are not replication compliant (there are schema differences in those tables)");
 }
 void CheckReplicationPrerequisities(IReplicationArticle article, Table sourceTable, Table targetTable)
 {
     IReplicationAnalyzer replicationAnalyzer = new ReplicationAnalyzer(_log);
     if (!replicationAnalyzer.AreTableSchemasReplicationCompliant(sourceTable, targetTable))
         throw new ReplicationException($"Source and target table {sourceTable.Name} are not replication compliant (there are schema differences in those tables)");
 }