Following code snippet demonstrates how to establish a connection using a specific FDO provider (in this case it's SDF Provider) and then use FDO.Filter to query a set of FDO Features based on a specific query condition.
OSGeo.FDO.IConnectionManager connManager = FeatureAccessManager.GetConnectionManager();
IConnection conn = connManager.CreateConnection("OSGeo.SDF.3.7");
conn.ConnectionInfo.ConnectionProperties.SetProperty("ReadOnly", false.ToString());
string fileName = @"C:\2013_Release\Map3D_2013\2013_API_Samples\Platform_API\Data\SDF\Roads.sdf";
conn.ConnectionInfo.ConnectionProperties.SetProperty("File", fileName);
conn.Open();
// Create the selection command
ISelect selCmd = (ISelect)conn.CreateCommand(CommandType.CommandType_Select);
Identifier id = new Identifier("Roads");
selCmd.FeatureClassName = id;
// Set a Filter to Select road Lengths greater than 6000 meter
OSGeo.FDO.Filter.Filter filter = OSGeo.FDO.Filter.Filter.Parse("LENGTH > 6000");
selCmd.Filter = filter;
IFeatureReader ftrRdr = selCmd.Execute();
ed.WriteMessage("\nStreet name --------------- Length \n");
while (ftrRdr.ReadNext())
{
string streetName = ftrRdr.GetString("ST_NAME");
double length = ftrRdr.GetDouble("LENGTH");
ed.WriteMessage(streetName + " " + length + "\n");
}
conn.Close();
Hope this is useful to you!