How do I refresh an sde connection to see updates to a feature class?

1056
4
05-30-2019 02:19 PM
JeremyRogers1
New Contributor II

I have created a button that fires a stand alone python script. The script will update a row in a feature class that exists in an sde. I have that same feature class in my map in the aprx. Once the script has fired I want to see the updated row in the attribute table. If I manually refresh the sde connection in my database connection folder inside the aprx it will not update the row. However, if I were to right-click on the sde database and select properties this will cause a "refresh" and the update will become visible in the attribute table. I am attempting to duplicate this "refresh" action in C# once the python script has finished but I'm striking out. Any suggestions would be appreciated.ArcGIS Pro SDK

0 Kudos
4 Replies
RichRuh
Esri Regular Contributor

Is this a versioned feature class?  And, if so, regular or branch versioning?

--Rich

0 Kudos
JeremyRogers1
New Contributor II

It is versioned using branch versioning.

0 Kudos
RichRuh
Esri Regular Contributor

The routine you are looking for is Version.Refresh

From the feature class, get the Geodatabase.  Geodatabase.GetVersionManager() will get you a VersionManager.  VersionManager.GetCurrentVersion() will get you a Version object.

--Rich

0 Kudos
JeremyRogers1
New Contributor II

Boom! Thank you!

Geodatabase gdb = layer.GetFeatureClass().GetDatastore() as Geodatabase;

VersionManager versionManager = gdb.GetVersionManager();

ArcGIS.Core.Data.Version version = versionManager.GetCurrentVersion();

version.Refresh();

Worked perfectly!