ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayerCreationParams Class / DefinitionQuery Property
Example

In This Topic
    DefinitionQuery Property (FeatureLayerCreationParams)
    In This Topic
    Gets and sets a definition query with name.
    Syntax
    public DefinitionQuery DefinitionQuery {get; set;}
    Public Property DefinitionQuery As DefinitionQuery
    Example
    Create layer with create-params
    var flyrCreatnParam = new FeatureLayerCreationParams(new Uri(@"c:\data\world.gdb\cities"))
    {
      Name = "World Cities",
      IsVisible = false,
      MinimumScale = 1000000,
      MaximumScale = 5000,
      // At 2.x - DefinitionFilter = new CIMDefinitionFilter()
      //{
      //  DefinitionExpression = "Population > 100000",
      //  Name = "More than 100k"
      //},
      DefinitionQuery = new DefinitionQuery(whereClause: "Population > 100000", name: "More than 100k"),
      RendererDefinition = new SimpleRendererDefinition()
      {
        SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(
          CIMColor.CreateRGBColor(255, 0, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
      }
    };
    
    var featureLayer = LayerFactory.Instance.CreateLayer<FeatureLayer>(
      flyrCreatnParam, map);
    Create a stream layer with a definition query
    //Must be on the QueuedTask
    var url = "https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer";
    var lyrCreateParam = new FeatureLayerCreationParams(new Uri(url))
    {
      IsVisible = true,
      //At 2.x - DefinitionFilter = new CIMDefinitionFilter()
      //{
      //  DefinitionExpression = "RWY = '29L'",
      //  Name = "Runway"
      //}
      DefinitionQuery = new DefinitionQuery(whereClause: "RWY = '29L'", name: "Runway")
    };
    
    var streamLayer = LayerFactory.Instance.CreateLayer<StreamLayer>(lyrCreateParam, map);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also