ArcObjects Library Reference (EditorExt)  

IObjectLoader2 Interface

Provides access to members that are used to load an object to an existing featureclass or table.

Product Availability

Available with ArcGIS Desktop.

Members

Description
Method LoadObjects Loads an object into an existing object class.
Method LoadObjectsTemplate Loads an object into an existing object class.

Inherited Interfaces

Interfaces Description
IObjectLoader Provides access to members that are used to load an object to an existing featureclass or table.

CoClasses that implement IObjectLoader2

CoClasses and Classes Description
ObjectLoader Loads data into an existing object class.
[C#]
// This example loads only the states of California and Oregon.
public void loadObjects(String output, String input, String outputFeatureClassName, String inputFeatureClassName)
{
    //Set up the output feature classes, i.e. the destination
    IWorkspaceFactory outputWorkspaceFactory = new AccessWorkspaceFactoryClass();

    IFeatureWorkspace outputFeatureWorkspace = outputWorkspaceFactory.OpenFromFile(output, 0) as IFeatureWorkspace;
    IFeatureClass outputFeatureClass = outputFeatureWorkspace.OpenFeatureClass(outputFeatureClassName);
    // Set up the input feature classe, i.e. the data source
    IWorkspaceFactory inFeatureWorkspaceFactory = new AccessWorkspaceFactoryClass();
    IFeatureWorkspace inFeatureWorkspace = inFeatureWorkspaceFactory.OpenFromFile(input, 0) as IFeatureWorkspace;
    IFeatureClass inFeatureClass = inFeatureWorkspace.OpenFeatureClass(inputFeatureClassName);
    // Specify a subset of the input data
    IQueryFilter queryFilter = new QueryFilterClass();
    queryFilter.SubFields = "SHAPE,STATE_NAME,STATE_FIPS,AREA";
    queryFilter.WhereClause = "STATE_NAME = 'California' OR STATE_NAME = 'Oregon'";

    //OutputFields parameter needs to match sub-fields in input queryfilter
    IFields allFields = outputFeatureClass.Fields;
    IFields outFields = new FieldsClass();
    IFieldsEdit outFieldsEdit = outFields as IFieldsEdit;
    // Get the query filter sub-fields as an array
    // and loop through each field in turn,
    // adding it to the ouput fields
    String[] subFields = (queryFilter.SubFields).Split(',');
    for(int j = 0; j < subFields.Length; j++)
    {
        int fieldID = allFields.FindField(subFields[j]);
        if(fieldID == -1)
        {
            System.Windows.Forms.MessageBox.Show("field not found: " +  subFields[j]);
            return;
        }
        outFieldsEdit.AddField(allFields.get_Field(fieldID));
    }

    IObjectLoader objectLoader = new ObjectLoaderClass();
    IEnumInvalidObject invalidObjectEnum;
    objectLoader.LoadObjects(
        null,
        (ITable)inFeatureClass,
        queryFilter,
        (ITable)outputFeatureClass,
        outFields,
        false,
        0,
        false,
        false,
        10,
        out invalidObjectEnum
    );
       
              
    IInvalidObjectInfo invalidObject = invalidObjectEnum.Next();
    if(invalidObject != null)
    {
        System.Windows.Forms.MessageBox.Show("Some or all features did not load");
    }
}