Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CosmosClone/CosmicCloneUI/SourcePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
Expand All @@ -38,10 +39,13 @@
<Label Content="Collection" Grid.Row="4" Grid.Column="0" Style="{StaticResource GridRowLabelStyle}" />
<TextBox x:Name="SourceCollection" Grid.Row="4" Grid.Column="1" Style="{StaticResource GridRowTextBoxStyle}"/>

<StackPanel Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="SelectCriteria" Grid.Row="5" Grid.Column="0" Style="{StaticResource GridRowLabelStyle}" />
<TextBox x:Name="SelectQuery" Text="SELECT * FROM c" Grid.Row="5" Grid.Column="1" Style="{StaticResource GridRowTextBoxStyle}"/>

<StackPanel Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Image x:Name="ConnectionIcon" Width="30" Height="30"/>
<Button Click="BtnTestSource" Content="Test Connection" Style="{StaticResource ButtonStyle}"/>
</StackPanel>
<TextBlock Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Name="ConnectionTestMsg" TextWrapping="Wrap" />
<TextBlock Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" Name="ConnectionTestMsg" TextWrapping="Wrap" />
</Grid>
</Page>
3 changes: 2 additions & 1 deletion CosmosClone/CosmicCloneUI/SourcePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public bool TestSourceConnection()
EndpointUrl = SourceURL.Text.ToString(),
AccessKey = SourceKey.Text.ToString(),
DatabaseName = SourceDB.Text.ToString(),
CollectionName = SourceCollection.Text.ToString()
CollectionName = SourceCollection.Text.ToString(),
SelectQuery = SelectQuery.Text.ToString()
};

var result = cosmosHelper.TestSourceConnection();
Expand Down
2 changes: 1 addition & 1 deletion CosmosClone/CosmosCloneCommon/Migrator/DocumentMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public async Task InitializeMigration()
{
TotalRecordsInSource = cosmosHelper.GetSourceRecordCount();
logger.LogInfo($"Total records in Source: {TotalRecordsInSource} ");
SourceCommonDataFetchQuery = cosmosHelper.GetSourceEntityDocumentQuery<dynamic>(sourceClient, CloneSettings.ReadBatchSize);
SourceCommonDataFetchQuery = cosmosHelper.GetSourceEntityDocumentQuery<dynamic>(sourceClient, CloneSettings.SourceSettings.SelectQuery, CloneSettings.ReadBatchSize);
await cosmosBulkImporter.InitializeBulkExecutor(targetClient, targetCollection);
}
else
Expand Down
1 change: 1 addition & 0 deletions CosmosClone/CosmosCloneCommon/Utility/CloneSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class CosmosCollectionValues
public string AccessKey { get; set; }
public string DatabaseName { get; set; }
public string CollectionName { get; set; }
public string SelectQuery { get; set; }
public int OfferThroughputRUs { get; set; }
}
}
5 changes: 2 additions & 3 deletions CosmosClone/CosmosCloneCommon/Utility/CosmosDBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,15 @@ public async Task<DocumentCollection> CreateTargetDocumentCollection(DocumentCli
}
}

public IQueryable<T> GetSourceEntityDocumentQuery<T>(DocumentClient sourceClient, int batchSize = -1)
public IQueryable<T> GetSourceEntityDocumentQuery<T>(DocumentClient sourceClient, string selectQuery, int batchSize = -1)
{
try
{
//var SourceCosmosDBSettings = CloneSettings.GetConfigurationSection("SourceCosmosDBSettings");
string sourceDatabaseName = CloneSettings.SourceSettings.DatabaseName;
string sourceCollectionName = CloneSettings.SourceSettings.CollectionName;
FeedOptions queryOptions = new FeedOptions { MaxItemCount = batchSize, EnableCrossPartitionQuery = true };
string EntityDataQuery = $"SELECT * FROM c";
var documentQuery = sourceClient.CreateDocumentQuery<T>(UriFactory.CreateDocumentCollectionUri(sourceDatabaseName, sourceCollectionName), EntityDataQuery, queryOptions);
var documentQuery = sourceClient.CreateDocumentQuery<T>(UriFactory.CreateDocumentCollectionUri(sourceDatabaseName, sourceCollectionName), selectQuery, queryOptions);
return documentQuery;
}
catch (Exception ex)
Expand Down