Example #1
0
        public void WriteDataToTarget()
        {
            for (int i = 0; i < datastore.Count; i++)
            {
                object[] rowData  = datastore[i];
                var      dbRecord = dataStoreConverter.ConvertToDbRecord(rowData);
                dbRecord.Identifiers = DbTargetHelper.BuildRecordIdentifiers(configuration, rowData, datastore.Metadata);

                var existingRecords = databaseTargetProvider.ResolveRecordInDatabase(dbRecord);

                UpsertRecordInDatabase(configuration.ImportMode, dbRecord, existingRecords);
            }
        }
Example #2
0
        public void WriteData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            reportProgress(new SimpleProgressReport("Aquire database-connection"));
            IDatabaseTargetProvider mySqlTarget = new MySqlTargetProvider(connection);

            DataStoreConverter dataStoreConverter = new DataStoreConverter(this.Configuration.TargetTable, dataObject.Metadata, this.Configuration.Mapping);

            reportProgress(new SimpleProgressReport("Write records to database"));
            for (int i = 0; i < dataObject.Count; i++)
            {
                object[] rowData  = dataObject[i];
                var      dbRecord = dataStoreConverter.ConvertToDbRecord(rowData);
                dbRecord.Identifiers = DbTargetHelper.BuildRecordIdentifiers((DbTargetCommonConfiguration)Configuration, rowData, dataObject.Metadata);

                var existingRecords = mySqlTarget.ResolveRecordInDatabase(dbRecord);

                UpsertRecordInDatabase(mySqlTarget, dbRecord, existingRecords);
            }
        }