Hi,
I have two layers where I need to change the dataSources using buttonClick. I'm currently using the code below, but I'm unable to change the dataSource of one of the layers because the SDE database does not contain the feature class with that name.
I'm using " Dataset = featureLayer.Name.Split('.').ToList().Last()" where it is looking for the exact name, but I need to match the data by its field rather than by its name Is there a way to do this, and if so, could someone please provide a code snippet?
*********Code snippet********
return QueuedTask.Run(() =>
{
CIMDataConnection currentDataConnection = featureLayer.GetDataConnection();
string connection = System.IO.Path.GetFullPath(catalogPath);
string suffix = System.IO.Path.GetExtension(connection).ToLower();
var workspaceConnectionString = string.Empty;
WorkspaceFactory wf = WorkspaceFactory.FileGDB;
if (suffix == ".sde")
{
wf = WorkspaceFactory.SDE;
var dbGdbConnection = new DatabaseConnectionFile(new Uri(connection, UriKind.Absolute));
workspaceConnectionString = new Geodatabase(dbGdbConnection).GetConnectionString();
CIMStandardDataConnection updatedDataConnection = new CIMStandardDataConnection()
{
WorkspaceConnectionString = workspaceConnectionString,
WorkspaceFactory = wf,
DatasetType = esriDatasetType.esriDTFeatureClass,
Dataset = featureLayer.Name.Split('.').ToList().Last()
};
***************************
Error which I'm getting because of Name

Thanks in advance!