I am using a RowCursor to build a List of Features. In the While loop, my debug statement returns OBJECTIDs 1 and 2, but in the For loop after the RowCursor, the OBJECTIDs are 2 and 2. Why?
Dim mm as MapMember
Dim pPointFeatures As List(Of Feature) = New List(Of Feature)
Dim qf as ArcGIS.Core.Data.QueryFilter
qf.WhereClause = "OBJECTID IN (1, 2)"
Using c As RowCursor = CType(mm, BasicFeatureLayer).Search(qf)
While c.MoveNext
Debug.Print(CType(c.Current, Feature).Item("OBJECTID").ToString())
' Prints 1 and 2
pPointFeatures.Add(CType(c.Current, Feature))
End While
End Using
For Each p In pPointFeatures
Debug.Print(p("OBJECTID").ToString())
' Prints 2 and 2
Next
I
Solved! Go to Solution.
Your code is using a recycling cursor (the default method). You have set the useRecyclingCursor parameter to false when using the Search method.
Using c As RowCursor = CType(mm, BasicFeatureLayer).Search(qf, false)
Read a little more about recycling cursors here
Your code is using a recycling cursor (the default method). You have set the useRecyclingCursor parameter to false when using the Search method.
Using c As RowCursor = CType(mm, BasicFeatureLayer).Search(qf, false)
Read a little more about recycling cursors here
Wow! Thanks! I never knew. Small note, I had to add GetTable() so I could use the Table Search and then it worked.
Using c As RowCursor = CType(mm, BasicFeatureLayer).GetTable().Search(qf, False)