This is DBMS specific, so it may not work if you are on a filegeodb, but you could
use something like PROP_ID NOT IN (select PROP_ID from FC1) in a query filter if your featureclasses aren't versioned.
This is really rough since I'm not at my workstation. This assumes you already have your IFeatureClass reference:
IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.WhereClause = "PROP_ID NOT IN (select PROP_ID from FC1";
IFeatureCursor cursor = featureClass.Search(queryFilter,true);
IFeature feature = null;
while ((feature = cur.NextFeature()) != null)
{
feature.get_Value(idx); // use the FindField to get idx like in Kirk's code sample
}
Not sure which .NET framework you are in, but if here is an extension method:
/// <summary>
/// Gets the field values for a featureclass
/// </summary>
/// <param name="featureclass">The feature class.</param>
/// <param name="fieldName">Name of the field.</param>
/// <param name="whereClause">where clause for queryfilter</param>
/// <returns>dictionary of int, object where int is the OBJECTID and object is the field value</returns>
public static Dictionary<int, object> GetFieldValues(this IFeatureClass featureclass, string fieldName, string whereClause)
{
Dictionary<int, object> dictionary = new Dictionary<int, object>();
IQueryFilter filter = new QueryFilterClass();
filter.SubFields = string.Format("{0},{1}", featureclass.OIDFieldName, fieldName);
filter.WhereClause = whereClause;
int fieldIndex = featureclass.Fields.FindField(fieldName);
if (fieldIndex > -1)
{
IFeatureCursor cursor = null;
try
{
cursor = featureclass.Search(filter, true);
IFeature feature = null;
while ((feature = cursor.NextFeature()) != null)
{
dictionary.Add(
feature.OID,
feature.get_Value(fieldIndex).Equals(System.DBNull.Value) ? null : feature.get_Value(fieldIndex));
}
}
catch
{
throw;
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
}
}
return dictionary;
}
And you can use it like this:
Dictionary<int, object> featClassFieldvalues = fc1.GetFieldValues("PROP_ID", string.Empty);
Dictionary<int, object> featClassFieldvalues2 = fc2.GetFieldValues("PROP_ID",string.Empty);
var v = featClassFieldvalues.Values.Except(featClassFieldvalues2.Values);