geoprocessing with a definition expression

Discussion created by gbilotta on May 10, 2013
Latest reply on May 13, 2013 by ldonahue
I am trying to use the Geoprocessor class to run a symmetrical difference on two layers with definition expressions on them in a console application.  Whenever I run the code, the symmetrical difference is run, but the definition expression is not taken into consideration.  Has anyone else tried to use a definition expression while using the geoprocessor class?  Thank you.

Here is what I have:

//create a new layer
IFeatureLayer arcFLayer1 = new FeatureLayer();
//assign the feature class
Layer1.FeatureClass = arcFClass1;
arcFLayer1.Name = 'Layer1';

//create a definition expression
IFeatureLayerDefinition2 arcFLayerDef1 = arcFLayer1 as IFeatureLayerDefinition2;
arcFLayerDef1.DefinitionExpression = "BDTYPE = 'F'";

//add it to a map object

//get the layer as a geofeaturelayer
IGeoFeatureLayer arcGeoFLayer1 = arcMapp.get_Layer(0) as IGeoFeatureLayer;

//create a new layer
IFeatureLayer arcFLayer2 = new FeatureLayer();
//assign the feature class
Layer2.FeatureClass = arcFClass2;
arcFLayer2.Name = 'Layer2';

//create a definition expression
IFeatureLayerDefinition2 arcFLayerDef2 = arcFLayer2 as IFeatureLayerDefinition2;
arcFLayerDef2.DefinitionExpression = "BDTYPE = 'F'";

//add it to a map object

//get the layer as a geofeaturelayer
IGeoFeatureLayer arcGeoFLayer2 = arcMapp.get_Layer(0) as IGeoFeatureLayer;

//create a geoprocessor objects
Geoprocessor GP = new Geoprocessor();

//setup the symmetrical difference
ESRI.ArcGIS.AnalysisTools.SymDiff arcSymDiff = new ESRI.ArcGIS.AnalysisTools.SymDiff();
arcSymDiff.in_features = arcGeoFLayer1.DisplayFeatureClass;
arcSymDiff.update_features = arcGeoFLayer2.DisplayFeatureClass ;
arcSymDiff.join_attributes = "ONLY_FID";

GP.Execute(arcSymDiff, null);