How to list all of feature class in SDE that started by "G" ?

4927
5
Jump to solution
03-02-2014 03:43 PM
TaiBui
by
Occasional Contributor II
Hi,

I am finding a statement to show or list all names of feature classes in SDE. Do you know this ?

Thanks and regards,

Tai
0 Kudos
1 Solution

Accepted Solutions
AhmedEl-Sisi
Occasional Contributor III
From SDK help:
Note that only the top-level datasets in the workspace are returned by these methods. In particular, if a workspace contains both stand-alone feature classes and additional feature classes that are part of a feature dataset, then calling the DatasetNames property on the workspace with a dataset type of esriDTFeatureClass will return only the standalone feature classes. In order to get the feature class names within a feature dataset, the application needs to get the FeatureClassNames property on the top-level feature dataset name returned by the workspace.

IWorkspace.DatasetNames Property will list all matched types for the top level only.

If your feature classes are inside featuredataset you should use IFeatureDatasetName.FeatureClassNames After you get your dataset.

View solution in original post

0 Kudos
5 Replies
ErinBrimhall
Occasional Contributor II
Here are a couple options.


Python:

import arcpy

arcpy.env.workspace = r"[Path to an SDE connection file goes here]"

featureClasses = arcpy.ListFeatureClasses("G*", "ALL")

for featureClass in featureClasses:
    print featureClass




C# / ArcObjects:

IWorkspaceFactory workspaceFactory = new WorkspaceFactory();
IWorkspace workspace = workspaceFactory.OpenFromFile("[Path to an SDE connection file goes here]", 0);

var namesEnum = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass];

var tempName = namesEnum.Next();
while (tempName != null)
{
    // Add string comparison logic here, e.g. tempName.Name.StartsWith("G")

    Console.WriteLine(tempName.Name)

    tempName = namesEnum.Next();
}

TaiBui
by
Occasional Contributor II
Thanks Erin Brimhall very much !
0 Kudos
TaiBui
by
Occasional Contributor II
Here are a couple options.


C# / ArcObjects:

IWorkspaceFactory workspaceFactory = new WorkspaceFactory();
IWorkspace workspace = workspaceFactory.OpenFromFile("[Path to an SDE connection file goes here]", 0);

var namesEnum = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass];

var tempName = namesEnum.Next();
while (tempName != null)
{
    // Add string comparison logic here, e.g. tempName.Name.StartsWith("G")

    Console.WriteLine(tempName.Name)

    tempName = namesEnum.Next();
}



Dear Erin Brimhall,

I am getting a problem: my SDE contains some feature classes, but after using the statement:

var namesEnum = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass];
var tempName = namesEnum.Next(); // get value null



The value of tempName is Null, but it is ok if I use esriDatasetType.esriDTFeatureDataset.

Do you know why ?

Thanks and regards,

Tai
0 Kudos
AhmedEl-Sisi
Occasional Contributor III
From SDK help:
Note that only the top-level datasets in the workspace are returned by these methods. In particular, if a workspace contains both stand-alone feature classes and additional feature classes that are part of a feature dataset, then calling the DatasetNames property on the workspace with a dataset type of esriDTFeatureClass will return only the standalone feature classes. In order to get the feature class names within a feature dataset, the application needs to get the FeatureClassNames property on the top-level feature dataset name returned by the workspace.

IWorkspace.DatasetNames Property will list all matched types for the top level only.

If your feature classes are inside featuredataset you should use IFeatureDatasetName.FeatureClassNames After you get your dataset.
0 Kudos
TaiBui
by
Occasional Contributor II
From SDK help:
Note that only the top-level datasets in the workspace are returned by these methods. In particular, if a workspace contains both stand-alone feature classes and additional feature classes that are part of a feature dataset, then calling the DatasetNames property on the workspace with a dataset type of esriDTFeatureClass will return only the standalone feature classes. In order to get the feature class names within a feature dataset, the application needs to get the FeatureClassNames property on the top-level feature dataset name returned by the workspace.

IWorkspace.DatasetNames Property will list all matched types for the top level only.

If your feature classes are inside featuredataset you should use IFeatureDatasetName.FeatureClassNames After you get your dataset.


Thanks Ahmed El Sisi
0 Kudos