1

I need to query two feature class at the same time using IQueryFIlter.

For eg -

FeatureClass -- A has field OBJECTID

FeatureClass -- B has field OBJECTID

what i am tring to do is --

IQueryFilter iqf = new QueryFilter();
iqf .setWhereClause(B+".OBJECTID = "+A+".OBJECTID");
IFeatureCursor resultCursor = B.search(iqf, false);  

Is this possible , if yes what is the correct methord because currently i am facing error--

"Too few parameters. Expected 1"

Might its not taking A.OBJECTID properly ////

2

It is difficult to do anything but the simplest queries in ArcObjects. Here is a method to create an in memory join between 2 tables.

public static ITable Join(string relationshipName, ITable tableA, ITable tableB, string tableAJoinField, string tableBJoinField, IQueryFilter queryF, string targetFields, esriJoinType joinType, esriRelCardinality cardinality)
        {
            IMemoryRelationshipClassFactory mrcFactory = new MemoryRelationshipClassFactoryClass();
            IRelationshipClass relationship = mrcFactory.Open(
                relationshipName,
                (IObjectClass)tableA, tableAJoinField,
                (IObjectClass)tableB, tableBJoinField,
                "forward", "backward",
                cardinality);

            // Open the RelQueryTable
            IRelQueryTableFactory rqtFactory = new RelQueryTableFactoryClass();

            bool joinForward = true;
            bool doNotPushJoinToDb = true;
            bool openAsLeftOuterJoin = (joinType == esriJoinType.esriLeftOuterJoin);

            IRelQueryTable relQueryTable = rqtFactory.Open(relationship, joinForward, queryF, null, targetFields, doNotPushJoinToDb, openAsLeftOuterJoin);
            ITable joinTable = relQueryTable as ITable;

            return joinTable;
        }
  • Thanks it helped a lot .Just waiting for some more suggetions , if not will mark yours as answer.//// – NewBee Jul 3 '13 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.