Obtaining Featureclass names From SDE file path for adding to map in .net SDK

475
7
Jump to solution
03-05-2024 10:28 PM
sumalain1
New Contributor III

hi  @GKmieliauskas @Wolf

how can I filter the following featureNameslist in the geodatabase created using Oracle SDE which don't have access to user:

Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path to sde")));

var featureNameslist = geodatabase.GetDefinitions<FeatureClassDefinition>().Select(def => def.GetName()).ToArray();

Just like in the catalog

0 Kudos
1 Solution

Accepted Solutions
sumalain1
New Contributor III

Thanks @Aashis for the reply,

The purpose to list feature classes from SDE is to add selected feature class to map. There are multiple owners in the sde, how will I know that which owner has access to the connected user of the SDE? Just like Catalog shows the accessible list of enterprise feature classes.

IReadOnlyList<FeatureClassDefinition> featureClassDefinitions = geodatabase.GetDefinitions<FeatureClassDefinition>();
List<string> allOwnerNames = featureClassDefinitions.Select(def =>
{
    SQLSyntax sqlSyntax = geodatabase.GetSQLSyntax();
    (string dbName, string ownerName, string tableName) = sqlSyntax.ParseTableName(def.GetName());

    return ownerName;
}).ToList();

List<string> distinctOwnerNames = allOwnerNames.Distinct().ToList();

View solution in original post

7 Replies
Aashis
by Esri Contributor
Esri Contributor

The following should work. Could you pls try?

The SQLSyntax parses the fully qualified dataset name to the db, owner, and dataset names.

 

IReadOnlyList<FeatureClassDefinition> featureClassDefinitions = geodatabase.GetDefinitions<FeatureClassDefinition>();
List<FeatureClassDefinition> filteredDefinitions = featureClassDefinitions.Where(def =>
{
SQLSyntax sqlSyntax = geodatabase.GetSQLSyntax();
(string dbName, string ownerName, string tableName) = sqlSyntax.ParseTableName(def.GetName());

return ownerName == "your_owner_name";
}).ToList();

 

sumalain1
New Contributor III

Thanks @Aashis for the reply,

The purpose to list feature classes from SDE is to add selected feature class to map. There are multiple owners in the sde, how will I know that which owner has access to the connected user of the SDE? Just like Catalog shows the accessible list of enterprise feature classes.

IReadOnlyList<FeatureClassDefinition> featureClassDefinitions = geodatabase.GetDefinitions<FeatureClassDefinition>();
List<string> allOwnerNames = featureClassDefinitions.Select(def =>
{
    SQLSyntax sqlSyntax = geodatabase.GetSQLSyntax();
    (string dbName, string ownerName, string tableName) = sqlSyntax.ParseTableName(def.GetName());

    return ownerName;
}).ToList();

List<string> distinctOwnerNames = allOwnerNames.Distinct().ToList();
sumalain1
New Contributor III

Hi @Aashis,

 how will I know that which owner has access to the connected user of the SDE?

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

I am presuming that you are trying to find the connected user.

 

DatabaseConnectionProperties connectionProperties= geodatabase.GetConnector() as DatabaseConnectionProperties;
string user = connectionProperties.User;

 

DatabaseConnectionProperties  

0 Kudos
sumalain1
New Contributor III

Hi @Aashis,

Thanks for the reply. But the user and owner are not same.  Any user can have access to multiple owners.

In Catalog, it is filtered correctly, do you know any way to filter that?

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

In ArcGIS, user accounts determine who owns what data. User accounts also provide a way to control what type of access a person or client application has to a database or geodatabase and its datasets. ArcGIS generally recommends that the owner and schema have matching names.

The Catalog UI does the following - 

 

 

 

// Get the currently logged user
DatabaseConnectionProperties connectionProperties= geodatabase.GetConnector() as DatabaseConnectionProperties;
string user = connectionProperties.User;

// Filter feature classes based on the user
IReadOnlyList<FeatureClassDefinition> featureClassDefinitions = geodatabase.GetDefinitions<FeatureClassDefinition>();
List<FeatureClassDefinition> filteredDefinitions = featureClassDefinitions.Where(def =>
{
	SQLSyntax sqlSyntax = geodatabase.GetSQLSyntax();
	(string dbName, string ownerName, string tableName) = sqlSyntax.ParseTableName(def.GetName());

	return ownerName == user;
}).ToList();

 

 

 

If you find something else, please log a bug from tech support for further investigation. 

0 Kudos
sumalain1
New Contributor III

Hi @Aashis,

Thanks for the reply, 

User accounts may have access to different owner's table which may not be owned by the user. In that case how to filter out only those tables from the below featureClassDefinitions:

IReadOnlyList<FeatureClassDefinition> featureClassDefinitions = geodatabase.GetDefinitions<FeatureClassDefinition>();

The Catalog UI displays only accessible feature classes with or without List only object owned by connecting user checkbox.

 

0 Kudos