static void Main(string[] args) { Geodatabase geo = Geodatabase.Open(""); List <Table> tables = new List <Table>(); List <string> featureClasses = geo.GetChildDatasets("\\", "Feature Class").ToList(); foreach (string featureClassName in featureClasses) { tables.Add(geo.OpenTable(featureClassName)); } string createTableSqlCommand = CreateTableColumns(tables[0].FieldInformation); FieldInfo fieldInfo = tables[0].FieldInformation; var fields = new List <string>(); for (int i = 0; i < fieldInfo.Count; i++) { fields.Add(fieldInfo.GetFieldName(i)); } var countStatements = $"SELECT * FROM VAULTSCOT_AUTH_POINT_OCT18"; RowCollection rows = geo.ExecuteSQL(countStatements); WKBReader reader = new WKBReader(); foreach (Row row in rows) { MultiPointShapeBuffer geometry = row.GetGeometry(); var point = geometry.Points; //MULTIPOINT (295512,712727,0) throwing format exception - Resolved in upcoming commit. var geometryWKT = processMultiPointBuffer(geometry); } var countEnumerator = rows.GetEnumerator(); List <object> fieldValues = new List <object>(); if (rows != null) { countEnumerator.MoveNext(); var shape = countEnumerator.Current["Shape"]; for (int i = 0; i < fieldInfo.Count - 1; i++) { var count = countEnumerator.Current[fields[i]]; fieldValues.Add(count); } } InsertTableValues(fieldValues, fieldInfo); }
static void Main(string[] args) { //var gdbPath = ConfigurationManager.AppSettings["gdb.path"]; var gdbPath = @"C:\temp\fgdb_test.gdb"; Geodatabase gdb = Geodatabase.Open(gdbPath); var rowCollection = gdb.ExecuteSQL(@"SELECT voiceZoneName.NAME_ID, voiceStreetAddress.NAME_ID FROM voiceZoneName, voiceStreetAddress WHERE voiceZoneName.NAME_ID = voiceStreetAddress.NAME_ID"); foreach (var row in rowCollection) { } }
public static void ReadData(string path) { try { Geodatabase geodatabase = Geodatabase.Open(path); foreach (var ds in geodatabase.GetChildDatasets("\\", string.Empty)) { string sqlStatement = @"SELECT * FROM " + ds.Substring(1); foreach (Row attrQueryRow in geodatabase.ExecuteSQL(sqlStatement)) { for (int nFieldNumber = 0; nFieldNumber < attrQueryRow.FieldInformation.Count; nFieldNumber++) { string fieldName = attrQueryRow.FieldInformation.GetFieldName(nFieldNumber); if (attrQueryRow.IsNull(fieldName)) { continue; } switch (attrQueryRow.FieldInformation.GetFieldType(nFieldNumber)) { case FieldType.SmallInteger: attrQueryRow.GetShort(fieldName); break; case FieldType.Integer: attrQueryRow.GetInteger(fieldName); break; case FieldType.Single: attrQueryRow.GetFloat(fieldName); break; case FieldType.Double: attrQueryRow.GetDouble(fieldName); break; case FieldType.String: attrQueryRow.GetString(fieldName); break; case FieldType.Date: attrQueryRow.GetDate(fieldName).ToShortTimeString(); break; case FieldType.OID: attrQueryRow.GetOID(); break; case FieldType.Geometry: byte[] shapeBuffer = attrQueryRow.GetGeometry().shapeBuffer; double[] vs = new double[shapeBuffer.Length / 8]; for (int i = 0; i < vs.Length; i++) { vs[i] = BitConverter.ToDouble(shapeBuffer, i * 8); } break; case FieldType.GUID: attrQueryRow.GetGUID(fieldName).ToString(); break; case FieldType.GlobalID: attrQueryRow.GetGlobalID().ToString(); break; default: break; } } } } geodatabase.Close(); } catch (Exception) { return; } }