I am relatively new to ArcGIS Pro SDK for .NET and C#. I am working on creating an app that performs some statistical calculations using a few geodatabase tables in a single geodatabase. There are two tables with unique, common field in both tables. I want to grab the rows where the unique ID are present in both tables. I only want data from specific columns in each tables. I was wondering if the best way to do this is by creating a queryTable or using a list or dictionary? If you recommend using a queryTable, why and is there any resources you recommend on learning how to use a queryTable? I tried using the ESRI Prosnippets. However, it does not have the information I need. I added some samples of codes I tried using the queryTable and what I would like to perform. The indentation was not copied correctly below.
namespace ToolName
{
public class ClassName
{
public List<string> Cokey { get; set; }
public All_Processes()
{
Cokey = new List<string>();
}
string gdbPath1 = "C:/...";
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(gdbPath1)))){
using(Table compTable = geodatabase.OpenDataset<Table>("Component")){
int cokey_count = 0;
using (RowCursor cursor = compTable.Search()){
while (cursor.MoveNext())
{
cokey_count++;
Cokey.Add(values);
//From this table, I want the cokey column, as well as the corresponding, Component_Rep column in the same table.
}
}
}
//Creating the Horizon query table
using (Table HzTable = geodatabase.OpenDataset<Table>("Horizon"))
{
QueryDef queryDef = new QueryDef
{
Tables = "Horizon",
SubFields = "Horizon.hzdept_r, Horizon.hzdepb_r, Horizon.awc_l,Horizon.awc_r, Horizon.awc_h, Horizon.wfifteenbar_l,Horizon.wfifteenbar_r, Horizon.wfifteenbar_h, Horizon.wtenthbar_l,Horizon.wtenthbar_r, Horizon.wtenthbar_h, Horizon.wthirdbar_l,Horizon.wthirdbar_r, Horizon.wthirdbar_h, Horizon.wsatiated_l, Horizon.wsatiated_r, Horizon.wsatiated_h",
};
QueryTableDescription queryTableDescription = new QueryTableDescription(queryDef)
{
Name = "HzTable",
PrimaryKeys = geodatabase.GetSQLSyntax().QualifyColumnName("Horizon", "OBJECTID")
};
Table queryTable = geodatabase.OpenQueryTable(queryTableDescription);
// After creating the query table, I want to perform the following statistical calculations if the cokey (unique ID) in both table present:
If(cokey==Cokey){
for (var x = 0; x > nu_cokey; x++)
{
//Calculating the soil thickness, rThick by subtracting the bottom soil depth, botDepth (hzdepb_r column) to the top soil depth, topDepth(Horizon.hzdept_r)
rThick = botDepth - topDepth;
//Calculating the representative low by using the minimum value of the soil property within a specific column, awc_l
rLow = Table.CalculateStatistics.Min(rLow, rLow_Value);
//there are more equations below
}
}