ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / Version Class / Reconcile Method / Reconcile(ReconcileOptions,PostOptions) Method
If ReconcileOptions.TargetVersion is not specified in reconcileOptions, then the target version is the Default version.
If PostOptions.TargetVersion is not specified in postOptions, then the target version is the Default version.
Example

In This Topic
    Reconcile(ReconcileOptions,PostOptions) Method
    In This Topic
    Reconciles and posts this version against a target version specified in reconcileOptions and postOptions. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    reconcileOptions
    If ReconcileOptions.TargetVersion is not specified in reconcileOptions, then the target version is the Default version.
    postOptions
    If PostOptions.TargetVersion is not specified in postOptions, then the target version is the Default version.

    Return Value

    An instance of ReconcileResult indicating the results of the operation.
    Exceptions
    ExceptionDescription
    reconcileOptions and/or postOptions is null.

    This operation is not supported in client-server mode because the data store supports multi-branch versioning.

    -or-

    Multi-branch versioning does not support a ConflictResolutionType that favors the target version.

    A Selection object specified in PartialPostSelections is not from a feature service feature class.

    -or-

    Reconcile cannot be performed in an active edit session.

    A geodatabase-related exception has occurred.
    This method or property must be called within the lambda passed to QueuedTask.Run
    Remarks
    If the underlying data store supports branch versioning and partial posting, this operation will post the data specified by PartialPostSelections to the Default version. In addition, after the partial posting operation is complete, the API will perform another Reconcile operation. This action may subsequently cause ReconcileResult.HasConflicts to be true.
    Example
    Illustrate version conflict information from a reconcile operation
    public void GetVersionConflictsInfoInUpdateDeleteType(ServiceConnectionProperties featureServiceConnectionProperties, string featureClassName)
    {
        // To illustrate the conflict between versions,
        // the feature is updated in the child version and deleted in the parent version.
    
        long featureObjectIDForEdit = Int64.MinValue;
    
        // Get branch versioned service
        using (Geodatabase fsGeodatabase = new Geodatabase(featureServiceConnectionProperties))
        using (VersionManager versionManager = fsGeodatabase.GetVersionManager())
        using (Version defaultVersion = versionManager.GetDefaultVersion())
        using (Geodatabase defaultGeodatabase = defaultVersion.Connect())
        using (FeatureClass defaultFeatureClass = defaultGeodatabase.OpenDataset<FeatureClass>(featureClassName))
        using (FeatureClassDefinition defaultFeatureClassDefinition = defaultFeatureClass.GetDefinition())
        {
            // Create a feature in the default version to edit in a branch
            defaultGeodatabase.ApplyEdits(() =>
            {
                using (RowBuffer rowBuffer = defaultFeatureClass.CreateRowBuffer())
                {
                    rowBuffer["NAME"] = "Loblolly Pine";
                    rowBuffer["TREEAGE"] = 1;
                    rowBuffer[defaultFeatureClassDefinition.GetShapeField()] = new MapPointBuilderEx(new Coordinate2D(1, 1),
              SpatialReferenceBuilder.CreateSpatialReference(4152, 0)).ToGeometry();
    
                    using (Feature feature = defaultFeatureClass.CreateRow(rowBuffer))
                    {
                        featureObjectIDForEdit = feature.GetObjectID();
                    }
                }
            });
    
            // Add newly created feature in the filter
            QueryFilter queryFilter = new QueryFilter { ObjectIDs = new List<long> { featureObjectIDForEdit } };
    
            // Create a branch version
            VersionDescription versionDescription = new VersionDescription("UpdateDeleteConflictType",
              "Update-Delete version conflict type", VersionAccessType.Private);
    
            // Edit the feature in the branch 
            using (Version editVersion = versionManager.CreateVersion(versionDescription))
            using (Geodatabase branchGeodatabase = editVersion.Connect())
            using (FeatureClass featureClass = branchGeodatabase.OpenDataset<FeatureClass>(featureClassName))
            using (RowCursor rowCursor = featureClass.Search(queryFilter, false))
            {
                branchGeodatabase.ApplyEdits(() =>
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {
                            row["TREEAGE"] = 100;
                            row["NAME"] = $"{row["Name"]}_EditInBranch";
                            row.Store();
                        }
                    }
                });
    
                // Delete the feature from the default version
                defaultFeatureClass.DeleteRows(queryFilter);
    
                // Reconcile options
                ReconcileOptions reconcileOptions = new ReconcileOptions(defaultVersion)
                {
                    ConflictResolutionType = ConflictResolutionType.FavorEditVersion,
                    ConflictDetectionType = ConflictDetectionType.ByRow,
                    ConflictResolutionMethod = ConflictResolutionMethod.Continue
                };
    
                // Reconcile with default
                ReconcileResult reconcileResult = editVersion.Reconcile(reconcileOptions);
    
                // Check for conflicts
                bool hasConflictsReconcileResults = reconcileResult.HasConflicts;
                bool hasConflictsAfterReconcile = editVersion.HasConflicts();
    
                // Fetch conflicts
                IReadOnlyList<Conflict> conflictsAfterReconcile = editVersion.GetConflicts();
    
                // Iterate conflicts
                foreach (Conflict conflict in conflictsAfterReconcile)
                {
                    // Object ID of row where conflict occurs
                    long objectId = conflict.ObjectID;
    
                    ConflictType conflictType = conflict.ConflictType;
    
                    IReadOnlyList<FieldValue> ancestorVersionValues = conflict.AncestorVersionValues;
                    object nameAncestor = ancestorVersionValues.FirstOrDefault(f => f.FieldName.Contains("NAME")).Value;
                    object treeAgeAncestor = ancestorVersionValues.FirstOrDefault(f => f.FieldName.Contains("TREEAGE")).Value;
    
                    IReadOnlyList<FieldValue> childVersionValues = conflict.ChildVersionValues;
                    object nameChild = childVersionValues.FirstOrDefault(f => f.FieldName.Contains("NAME")).Value;
                    object treeAgeChild = childVersionValues.FirstOrDefault(f => f.FieldName.Contains("TREEAGE")).Value;
    
                    IReadOnlyList<FieldValue> parentVersionValues = conflict.ParentVersionValues;
    
                    IReadOnlyList<Field> originalFields = defaultFeatureClassDefinition.GetFields();
    
                    string datasetName = conflict.DatasetName;
                }
            }
        }
    }
    
    Reconciling and Posting a Version with its Parent in the same edit session
    public void ReconcileAndPost2(Geodatabase geodatabase)
    {
        // Get a reference to our version and our parent
        if (geodatabase.IsVersioningSupported())
        {
            using (VersionManager versionManager = geodatabase.GetVersionManager())
            using (Version currentVersion = versionManager.GetCurrentVersion())
            using (Version parentVersion = currentVersion.GetParent())
            {
    
                //// Create a ReconcileDescription object
                //At 2.x - 
                //ReconcileDescription reconcileDescription = new ReconcileDescription(parentVersion);
                //reconcileDescription.ConflictResolutionMethod = ConflictResolutionMethod.Continue; // continue if conflicts are found
                //reconcileDescription.WithPost = true;
    
                //// Reconcile and post
                //ReconcileResult reconcileResult = currentVersion.Reconcile(reconcileDescription);
    
                // ReconcileResult.HasConflicts can be checked as-needed
    
                // Create a ReconcileOptions object
                ReconcileOptions reconcileOptions = new ReconcileOptions(parentVersion);
                reconcileOptions.ConflictResolutionMethod = ConflictResolutionMethod.Continue; // continue if conflicts are found
                reconcileOptions.ConflictDetectionType = ConflictDetectionType.ByRow; //Default
                reconcileOptions.ConflictResolutionType = ConflictResolutionType.FavorTargetVersion;//or FavorEditVersion
    
                PostOptions postOptions = new PostOptions(parentVersion);
                //var postOptions = new PostOptions(); for default version
                postOptions.ServiceSynchronizationType = ServiceSynchronizationType.Synchronous;//Default
    
                // Reconcile
                ReconcileResult reconcileResult = currentVersion.Reconcile(reconcileOptions, postOptions);
                if (reconcileResult.HasConflicts)
                {
                    //TODO resolve conflicts
    
                }
    
            }
        }
    }
    Partial Posting
    // Partial posting allows developers to post a subset of changes made in a version.
    // One sample use case is an electric utility that uses a version to design the facilities in
    // a new housing subdivision. At some point in the process, one block of new houses have been
    // completed, while the rest of the subdivision remains unbuilt.  Partial posting allows the user
    // to post the completed work, while leaving not yet constructed features in the version to be
    // posted later. Partial posting requires a branch-versioned feature service using ArcGIS
    // Enterprise 10.9 and higher
    
    // Specify a set of features that were constructed
    QueryFilter constructedFilter = new QueryFilter()
    {
        WhereClause = "ConstructedStatus = 'True'"
    };
    // This selection represents the inserts and updates to the support
    // structure feature class that we wish to post
    using (Selection constructedSupportStructures = supportStructureFeatureClass.Select(constructedFilter, SelectionType.ObjectID, SelectionOption.Normal))
    {
        // Specifying which feature deletions you wish to post is slightly trickier, since you cannot issue
        // a query to fetch a set of deleted features Instead, a list of ObjectIDs must be used
        using (Selection deletedSupportStructures = supportStructureFeatureClass.Select(
                                            null, SelectionType.ObjectID, SelectionOption.Empty))
        {
            deletedSupportStructures.Add(deletedSupportStructureObjectIDs);  //deletedSupportStructureObjectIDs is
                                                                             //defined as List<long>
    
            //Perform the reconcile with partial post
            //At 2.x - 
            //ReconcileDescription reconcileDescription = new ReconcileDescription();
            //reconcileDescription.ConflictDetectionType = ConflictDetectionType.ByColumn;
            //reconcileDescription.ConflictResolutionMethod = ConflictResolutionMethod.Continue;
            //reconcileDescription.ConflictResolutionType = ConflictResolutionType.FavorEditVersion;
            //reconcileDescription.PartialPostSelections = new List<Selection>() { constructedSupportStructures, deletedSupportStructures };
            //reconcileDescription.WithPost = true;
    
            //ReconcileResult reconcileResult = designVersion.Reconcile(reconcileDescription);
    
            ReconcileOptions reconcileOptions = new ReconcileOptions();//reconcile against Default
            reconcileOptions.ConflictDetectionType = ConflictDetectionType.ByColumn;
            reconcileOptions.ConflictResolutionMethod = ConflictResolutionMethod.Continue;
            reconcileOptions.ConflictResolutionType = ConflictResolutionType.FavorEditVersion;
    
            PostOptions postOptions = new PostOptions();//post against Default
            postOptions.PartialPostSelections = new List<Selection>() {
                  constructedSupportStructures, deletedSupportStructures };
            postOptions.ServiceSynchronizationType = ServiceSynchronizationType.Synchronous;
    
            ReconcileResult reconcileResult = designVersion.Reconcile(reconcileOptions, postOptions);
    
            //TODO process result(s)
        }
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also