Geodatabase transactions

This sample demonstrates how to manage edits to a local geodatabase inside of transactions.

Manage geodatabase edits with transactions

Instructions

When the sample loads, a local geodatabase will be generated for a small area from the SaveTheBay feature service. When the geodatabase is ready, its tables are added as feature layers and the map view zooms to the extent of the local data. Use the UI controls to make edits either inside or outside of a transaction. If made in a transaction, you can rollback or commit your edits as a single unit when you choose to stop editing. To allow edits without a transaction, clear the Require transaction check box. If this box isn't checked, you add features directly into the local geodatabase. When done adding features, you can synchronize your local edits with the service.

Code

<UserControl 
    x:Class="ArcGISRuntime.UWP.Samples.GeodatabaseTransactions.GeodatabaseTransactions"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:MapView x:Name="MyMapView"/>
        <Border Width="465" Height="150" 
                HorizontalAlignment="Center" VerticalAlignment="Top"
                Margin="0,30" 
                CornerRadius="10" BorderBrush="DarkGray" BorderThickness="2"
                Background="LightGray" Opacity="1.0">
            <StackPanel Orientation="Vertical">
                <StackPanel x:Name="EditToolsPanel" 
                            Orientation="Horizontal"
                            Margin="5,10,0,0">
                    <Button x:Name="StartEditingButton" 
                            Content="Start Editing"
                            IsEnabled="False"
                            Width="100" Height="35"
                            Margin="2,0"
                            Click="BeginTransaction"/>
                    <Button x:Name="AddBirdButton" 
                            Content="Add Bird"
                            IsEnabled="False"
                            Width="80" Height="35"
                            Margin="2,0"
                            Click="AddNewFeature"/>
                    <Button x:Name="AddMarineButton" 
                            Content="Add Marine"
                            IsEnabled="False"
                            Width="100" Height="35"
                            Margin="2,0"
                            Click="AddNewFeature"/>
                    <Button x:Name="StopEditingButton"
                            Content="Stop Editing" 
                            IsEnabled="False"
                            Width="100" Height="35"
                            Margin="2,0"
                            Click="StopEditTransaction"/>
                    <Button x:Name="SyncEditsButton"
                            Content="Sync" 
                            IsEnabled="True"
                            Width="50" Height="35"
                            Margin="2,0"
                            Click="SynchronizeEdits"/>
                </StackPanel>
                <CheckBox x:Name="RequireTransactionCheckBox"
                          Content="Require a transaction for edits"
                          Margin="8,3"
                          IsChecked="True"
                          Click="RequireTransactionChanged"/>
                <TextBlock x:Name="MessageTextBlock"
                           Text="Generating local geodatabase ..." 
                           Foreground="Blue"
                           Height="40"
                           Margin="5"
                           TextWrapping="Wrap"/>
                <ProgressBar x:Name="LoadingProgressBar" 
                             Height="10"
                             Margin="3"
                             IsIndeterminate="True"
                             Opacity="0.5"/>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>


In this topic
  1. Instructions
  2. Code