<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Search on IFeatureSelection using field from a Join Layer in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/search-on-ifeatureselection-using-field-from-a/m-p/331621#M8624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've got a tool that needs to operate on a selected set of features in a layer.&amp;nbsp; It then needs to process a subset of the selected features based on a query filter.&amp;nbsp; This is straightforward.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureSelection pFSel = (IFeatureSelection)pFLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ISelectionSet pSelectionSet = pFSel.SelectionSet;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IQueryFilter pQF = new QueryFilter();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pQF.WhereClause = "MATERIAL = 'PL';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureCursor pCursor;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pSelectionSet.Search(pQF, true, out pCursor);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And pCursor holds the result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;Now&lt;/SPAN&gt;&lt;SPAN&gt;, what if the layer in question is a join layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I want to select from the join layer using a field in the joined table I can use SearchDisplayFeatures on IGeoFeatureLayer, as in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IGeoFeatureLayer pGeoFLayer = (IGeoFeatureLayer)pFLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pCursor = pGeoFLayer.SearchDisplayFeatures(pQF, true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which works fine.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;But&lt;/SPAN&gt;&lt;SPAN&gt; if I want to subset an existing selection set using a query filter that references a field in the join table... well, I'm stumped.&amp;nbsp; Any suggestions would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Dec 2013 22:52:35 GMT</pubDate>
    <dc:creator>EdwardBlair</dc:creator>
    <dc:date>2013-12-06T22:52:35Z</dc:date>
    <item>
      <title>Search on IFeatureSelection using field from a Join Layer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/search-on-ifeatureselection-using-field-from-a/m-p/331621#M8624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've got a tool that needs to operate on a selected set of features in a layer.&amp;nbsp; It then needs to process a subset of the selected features based on a query filter.&amp;nbsp; This is straightforward.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureSelection pFSel = (IFeatureSelection)pFLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ISelectionSet pSelectionSet = pFSel.SelectionSet;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IQueryFilter pQF = new QueryFilter();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pQF.WhereClause = "MATERIAL = 'PL';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureCursor pCursor;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pSelectionSet.Search(pQF, true, out pCursor);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And pCursor holds the result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;Now&lt;/SPAN&gt;&lt;SPAN&gt;, what if the layer in question is a join layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I want to select from the join layer using a field in the joined table I can use SearchDisplayFeatures on IGeoFeatureLayer, as in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IGeoFeatureLayer pGeoFLayer = (IGeoFeatureLayer)pFLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pCursor = pGeoFLayer.SearchDisplayFeatures(pQF, true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which works fine.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;But&lt;/SPAN&gt;&lt;SPAN&gt; if I want to subset an existing selection set using a query filter that references a field in the join table... well, I'm stumped.&amp;nbsp; Any suggestions would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Dec 2013 22:52:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/search-on-ifeatureselection-using-field-from-a/m-p/331621#M8624</guid>
      <dc:creator>EdwardBlair</dc:creator>
      <dc:date>2013-12-06T22:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Search on IFeatureSelection using field from a Join Layer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/search-on-ifeatureselection-using-field-from-a/m-p/331622#M8625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After some sleep I realized the solution to the problem was to create a new selection layer from the first layer that had the join, and then use SearchDisplayFeatures on the selection layer.&amp;nbsp; Briefly, key parts of this are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Get a reference to the join table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IDisplayTable displayTable = (IDisplayTable)pFLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ITable table = displayTable.DisplayTable;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IRelQueryTable relQueryTable = (IRelQueryTable)table;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ITable destTable = relQueryTable.DestinationTable;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IDataset tableDS = (IDataset)destTable;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// Create a temporary layer using the selection set from the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// current layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureLayerDefinition pFLayerDef = (IFeatureLayerDefinition) pFLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureLayer pTempLayer = pFLayerDef.CreateSelectionLayer(pFLayer.Name + "_xxTemp", true,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; tableDS.Name, "");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// Search the new layer.. pCursor has the results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IGeoFeatureLayer pGeoFLayer = (IGeoFeatureLayer)pTempLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pCursor = pGeoFLayer.SearchDisplayFeatures(pQF, true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Remove the temporary layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;m_pMap.DeleteLayer((ILayer)pTempLayer);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Its probably not the intent of this forum for someone to ask a question and then later answer it themselves -- but it may be that writing the question down helped me solve it.&amp;nbsp; I don't think I get points for this.&amp;nbsp; Anyway, thanks Forums!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Dec 2013 14:28:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/search-on-ifeatureselection-using-field-from-a/m-p/331622#M8625</guid>
      <dc:creator>EdwardBlair</dc:creator>
      <dc:date>2013-12-07T14:28:46Z</dc:date>
    </item>
  </channel>
</rss>

