I am creating a table using the following code.
public async Task MakeQueryTable() {
var created = await QueuedTask.Run(() => {
bool tableCreated = false;
string featureClassPath = @"c:\temp\test.gdb\in_featureclass";
string tablePath = @"c:\temp\test.gdb\in_datatable";
var valueArray = Geoprocessing.MakeValueArray(featureClassPath + ";" + tablePath, "queryTable", "USE_KEY_FIELDS", null,
"in_featureclass.OBJECTID #; in_featureclass.ID #; in_featureclass.NAME #; in_datatable.ID #; in_datatable.NAME",
"in_featureclass.ID = in_datatable.ID And in_featureclass.NAME = in_datatable.NAME");
// Execute the task and DO NOT add the table to the current map!
Task<IGPResult> gp_result = Geoprocessing.ExecuteToolAsync("management.MakeQueryTable", valueArray, flags: GPExecuteToolFlags.None);
IGPResult makeTableResult = gp_result.Result;
// makeTableResult now contains the name "queryTable"
// Trying to open the table via
string newTablePath = @"c:\temp\test.gdb\" + makeTableResult.ReturnValue;
// Opening this table leads to an error not able to open this table, because it dous not exist in Filegeodatabase
// If you use GPExecuteToolFlags.AddOutputsToMap in ExecuteToolAsync then you can reference the table in the map
var newStandaloneTable = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().Where((l) => l.Name == "queryTable").FirstOrDefault() as StandaloneTable;
return tableCreated;
});
}I used the option GPExecuteToolFlags.None, because the result is just a temporary table.
After executing the code, I found no way to get the table object from the GP-Result.
There is a workaround. When you add the table to the active map, the you can find the table there.
var newStandaloneTable = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().Where((l) => l.Name == "queryTable").FirstOrDefault() as StandaloneTable;
Is there a way to get the table object without adding the result to the active map?