Thanks for the quick response. I still have some concerns about getting the "right" list of feature classes to use but I have enough to work with. Here's the code I came up with:
using ArcGIS.Core.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Version = ArcGIS.Core.Data.Version;
namespace MyNameSpace
{
public class VersionChangesService
{
public List<VersionChanges> GetChanges(Version version, List<string> featureclassnames)
{
List<VersionChanges> retval = new List<VersionChanges>();
foreach (var item in featureclassnames)
{
retval.Add(GetVersionChangesByFeatureClass(version, item));
}
return retval;
}
private VersionChanges GetVersionChangesByFeatureClass(Version version, string featureclassname)
{
using (Geodatabase versiongdb = version.Connect())
{
using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
{
using (FeatureClass defaultFc = geodatabase.OpenDataset<FeatureClass>(featureclassname))
{
using (FeatureClass versionFc = versiongdb.OpenDataset<FeatureClass>(featureclassname))
{
List<VersionChange> diffs = GetAllDifferences(defaultFc, versionFc);
return new VersionChanges { featureClass = versionFc, Changes = diffs };
}
}
}
}
}
private List<VersionChange> GetAllDifferences(FeatureClass defaultFc, FeatureClass versionFc)
{
List<VersionChange> retval = new List<VersionChange>();
retval.AddRange(GetDifferences(defaultFc, versionFc, DifferenceType.DeleteNoChange));
retval.AddRange(GetDifferences(defaultFc, versionFc, DifferenceType.DeleteUpdate));
retval.AddRange(GetDifferences(defaultFc, versionFc, DifferenceType.Insert));
retval.AddRange(GetDifferences(defaultFc, versionFc, DifferenceType.UpdateDelete));
retval.AddRange(GetDifferences(defaultFc, versionFc, DifferenceType.UpdateNoChange));
retval.AddRange(GetDifferences(defaultFc, versionFc, DifferenceType.UpdateUpdate));
return retval;
}
private List<VersionChange> GetDifferences(FeatureClass defaultFc, FeatureClass versionFc, DifferenceType differenceType)
{
List<VersionChange> retval = new List<VersionChange>();
using (DifferenceCursor differenceCursor = versionFc.Differences(defaultFc, differenceType))
{
List<long> diffs = new List<long>();
while (differenceCursor.MoveNext())
{
using (Row current = differenceCursor.Current)
{
diffs.Add(differenceCursor.ObjectID);
}
}
retval.AddRange(diffs.Select(s => new VersionChange { objectId = s, differenceType = DifferenceType.DeleteNoChange }));
}
return retval;
}
}
public class VersionChange
{
public DifferenceType differenceType { get; set; }
public long objectId { get; set; }
}
public class VersionChanges
{
public FeatureClass featureClass { get; set; }
public List<VersionChange> Changes { get; set; }
}
}