How can I select select item in attribute table and highlight on mapview?

2068
4
Jump to solution
02-09-2021 12:50 AM
PitchYen
New Contributor

I using ArcGIS Pro sdk to make an addin that can select item in attribute table by defined objectid,

But my ArcGIS Pro always freeze after I run this code.

var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Contains("Electric Device")).FirstOrDefault();

QueryFilter queryFilter = new QueryFilter
{
WhereClause = "OBJECTID = 12227"
};

featureLayer.Select(queryFilter);

 

0 Kudos
2 Solutions

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

Select  must be called on the MCT. Use QueuedTask.Run:

await QueuedTask.Run(() =>
{
QueryFilter queryFilter = new QueryFilter
{
WhereClause = "OBJECTID = 12227"
};

featureLayer.Select(queryFilter);
});

 

View solution in original post

GKmieliauskas
Esri Regular Contributor

WhereClause = "OBJECTID IN (1, 2, ....)"

or best way to use .ObjectIDs property of QueryFilter

.ObjectIDs = oids // Where oids is List<long>

View solution in original post

4 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Select  must be called on the MCT. Use QueuedTask.Run:

await QueuedTask.Run(() =>
{
QueryFilter queryFilter = new QueryFilter
{
WhereClause = "OBJECTID = 12227"
};

featureLayer.Select(queryFilter);
});

 

PitchYen
New Contributor

Thank you very much for your answer. I've created new method use your code and it work.

Maybe it freeze because I put it in using( ... ) bucket.

I have one more question

if I have to select 10000 items how can I write SQL statement for this one.

It always return message 'An invalid SQL statement was used.'

WhereClause = "OBJECTID = 1 Or OBJECTID = 137 Or ... 14355".

0 Kudos
GKmieliauskas
Esri Regular Contributor

WhereClause = "OBJECTID IN (1, 2, ....)"

or best way to use .ObjectIDs property of QueryFilter

.ObjectIDs = oids // Where oids is List<long>

sumalain1
New Contributor III

@GKmieliauskas  How can we use WhereClause = "OBJECTID IN ObjectIDs" where the ObjectID collection is more than 1000 and there is a limitation in oracle sde?

0 Kudos