Select to view content in your preferred language

Find graphic by Attribute

3710
2
05-25-2015 10:57 AM
PeterBennett
Deactivated User

Hello All,

I have a collection of graphics, I've added an attribute called "Id" for each graphic.

What would be the best way to find a graphic by its Id?

Do I have to iterate all the collection?

Please advice

Best Regards

0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

You can use Linq to query the Graphics collection for Graphics with attribute ["Id"] which match the specified value.

Cheers

Mike

KeithGemeinhart
Regular Contributor

Something like this should work ....

var graphics = new GraphicCollection();

graphics = // your code here

int interestingId = 1;

var interestingGraphic = graphics.FirstOrDefault( g =>  (int) g.Attributes["Id"] == interestingId);