Select to view content in your preferred language

Migrating from 2.9 to 3.0: FeatueLayer.RemoveAllDefinitionFilters() replaced by FeatureLayer.RemoveAllDefinitionQueries()?

810
2
Jump to solution
07-05-2022 10:46 AM
Amadeus111
Frequent Contributor

I am updating my AddIns and switching to SDK 3.0/.Net 6 

FeatueLayer.RemoveAllDefinitionFilters() is not resolved the closest function I found is FeatureLayer.RemoveAllDefinitionQueries().  The same issue exists also with FeatureLayer.DefinitionFilter but there is FeatureLayer.DefinitionQuery. I still have many errors I can't run my AddIn. Is there anyone who knows my assumption is right? 

https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic11585.html

 

Amadeus111_0-1657042998981.png

 

0 Kudos
2 Solutions

Accepted Solutions
CharlesMacleod
Esri Regular Contributor

that is correct. RemoveAllDefinitionQueries() will do the same thing

View solution in original post

UmaHarano
Esri Regular Contributor

Hi,

 

At 3.0, BasicFeatureLayer definition queries have changed.  The ProConcepts: 3.0 Migration Guide covers this topic.  There are also various code snippets that can help you in this wiki.

 

 var us_states = MapView.Active.Map.GetLayersAsFlattenedList()
                     .OfType<FeatureLayer>().First(lyr => lyr.Name == "US States");

 QueuedTask.Run(() => {
    us_states.SetDefinitionQuery("STATE_NAME = 'Iowa'");
    //equivalent to...
    var def_query = new DefinitionQuery() {
      Name = "A Name that is Unique",
      WhereClause = "STATE_NAME = 'Iowa'"
   };
   us_states.InsertDefinitionQuery(def_query, true);

   var active_def_query = us_states.ActiveDefinitionQuery;
   string where_clause = us_states.DefinitionQuery;//just the where clause string
   
  //remove the active query
  us_states.RemoveActiveDefinitionQuery();

  //remove using name
  us_states.RemoveDefinitionQueries(new List<string> { def_query.Name });

  //use LINQ to get just a specific query
  var def_query = us_states.DefinitionQueries.FirstOrDefault(
                                         dq => dq.Name == "Query def name");

 

View solution in original post

2 Replies
CharlesMacleod
Esri Regular Contributor

that is correct. RemoveAllDefinitionQueries() will do the same thing

UmaHarano
Esri Regular Contributor

Hi,

 

At 3.0, BasicFeatureLayer definition queries have changed.  The ProConcepts: 3.0 Migration Guide covers this topic.  There are also various code snippets that can help you in this wiki.

 

 var us_states = MapView.Active.Map.GetLayersAsFlattenedList()
                     .OfType<FeatureLayer>().First(lyr => lyr.Name == "US States");

 QueuedTask.Run(() => {
    us_states.SetDefinitionQuery("STATE_NAME = 'Iowa'");
    //equivalent to...
    var def_query = new DefinitionQuery() {
      Name = "A Name that is Unique",
      WhereClause = "STATE_NAME = 'Iowa'"
   };
   us_states.InsertDefinitionQuery(def_query, true);

   var active_def_query = us_states.ActiveDefinitionQuery;
   string where_clause = us_states.DefinitionQuery;//just the where clause string
   
  //remove the active query
  us_states.RemoveActiveDefinitionQuery();

  //remove using name
  us_states.RemoveDefinitionQueries(new List<string> { def_query.Name });

  //use LINQ to get just a specific query
  var def_query = us_states.DefinitionQueries.FirstOrDefault(
                                         dq => dq.Name == "Query def name");