private static void TestFilteredSelectCommand(FdoISelect selectCmd) { selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); FdoIFeatureReader reader = selectCmd.Execute(); try { int count = 0; FdoFeatureClass clsDef = reader.GetClassDefinition() as FdoFeatureClass; Assert.NotNull(clsDef); FdoFgfGeometryFactory geomFact = FdoFgfGeometryFactory.GetInstance(); FdoGeometricPropertyDefinition geomProp = clsDef.GetGeometryProperty(); string geomName = geomProp.Name; Assert.NotNull(geomProp); while (reader.ReadNext()) { string name = null; string key = null; string mapkey = null; if (!reader.IsNull("NAME")) { name = reader.GetString("NAME"); } if (!reader.IsNull("KEY")) { key = reader.GetString("KEY"); } if (!reader.IsNull("MAPKEY")) { mapkey = reader.GetString("MAPKEY"); } if (!reader.IsNull(geomName)) { FdoByteArrayHandle fgf = reader.GetGeometryBytes(geomName); Assert.NotNull(fgf); FdoIGeometry geom = geomFact.CreateGeometryFromFgf(fgf); Assert.NotNull(geom); string wkt = geom.Text; Assert.NotNull(wkt); Assert.NotEmpty(wkt); } count++; } Assert.Equal(66, count); } finally { reader.Close(); } }
private static int GetInsertedFeatures(FdoIInsert insertCmd) { FdoIFeatureReader reader = insertCmd.Execute(); int inserted = 0; try { while (reader.ReadNext()) { inserted++; } } finally { reader.Close(); } return(inserted); }
private void DoDelete(FdoIConnection conn) { string geomName = null; FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema; Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.NotNull(schemas); FdoFeatureClass clsDef = schemas.GetClassDefinition(null, "World_Countries") as FdoFeatureClass; Assert.NotNull(clsDef); FdoGeometricPropertyDefinition geomProp = clsDef.GetGeometryProperty(); Assert.NotNull(geomProp); geomName = geomProp.Name; FdoIDelete deleteCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Delete) as FdoIDelete; Assert.NotNull(deleteCmd); deleteCmd.SetFeatureClassName("World_Countries"); deleteCmd.SetFilter("NAME = 'Canada'"); int updated = deleteCmd.Execute(); Assert.Equal(66, updated); FdoISelect selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Select) as FdoISelect; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); FdoIFeatureReader fr = selectCmd.Execute(); Assert.False(fr.ReadNext()); fr.Close(); }
private static int GetFeatureCountForMapKey(FdoIConnection conn, string key) { FdoISelect selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Select) as FdoISelect; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("MAPKEY = '" + key + "'"); FdoIFeatureReader selReader = selectCmd.Execute(); int count = 0; try { while (selReader.ReadNext()) { count++; } } finally { selReader.Close(); } return(count); }
private void DoUpdate(FdoIConnection conn) { string geomName = null; FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema; Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.NotNull(schemas); FdoFeatureClass clsDef = schemas.GetClassDefinition(null, "World_Countries") as FdoFeatureClass; Assert.NotNull(clsDef); FdoGeometricPropertyDefinition geomProp = clsDef.GetGeometryProperty(); Assert.NotNull(geomProp); geomName = geomProp.Name; FdoIUpdate updateCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Update) as FdoIUpdate; Assert.NotNull(updateCmd); updateCmd.SetFeatureClassName("World_Countries"); updateCmd.SetFilter("NAME = 'Canada'"); FdoFgfGeometryFactory geomFactory = FdoFgfGeometryFactory.GetInstance(); FdoPropertyValueCollection propVals = updateCmd.GetPropertyValues(); FdoStringValue nameVal = FdoStringValue.Create(); Assert.True(nameVal.IsNull()); FdoStringValue keyVal = FdoStringValue.Create(); Assert.True(keyVal.IsNull()); FdoStringValue mapkeyVal = FdoStringValue.Create(); Assert.True(mapkeyVal.IsNull()); FdoGeometryValue geomVal = FdoGeometryValue.Create(); Assert.True(geomVal.IsNull()); FdoPropertyValue pKey = FdoPropertyValue.Create("KEY", keyVal); FdoPropertyValue pMapKey = FdoPropertyValue.Create("MAPKEY", mapkeyVal); propVals.Add(pKey); propVals.Add(pMapKey); //Set the actual values keyVal.String = "MOC"; mapkeyVal.String = "MOC123"; int updated = updateCmd.Execute(); Assert.Equal(66, updated); FdoISelect selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Select) as FdoISelect; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); FdoIFeatureReader fr = selectCmd.Execute(); while (fr.ReadNext()) { Assert.False(fr.IsNull("KEY")); Assert.False(fr.IsNull("MAPKEY")); Assert.Equal(fr.GetString("KEY"), "MOC"); Assert.Equal(fr.GetString("MAPKEY"), "MOC123"); } fr.Close(); }