The following code samples are a representative listing of the capability methods in each category. For a complete listing consult the API reference documentation.
The capabilities for a provider are statically defined. You create a connection object for the provider and use this object to query the capabilities. The connection does not have to be open.
Some capabilities are defined as booleans, for example, support for the DISTINCT operator in a SQL SELECT statement. Sample code for this is shown in the Command section. Some capabilities are defined by arrays of enumerated type values, for example, the feature commands. The presence of the capability is determined by testing each value in the array for its equality with one of the values in the enumerated type range; sample code that tests for the presence of the create data store command is shown in the Command section.
The schema capabilities include a string type that defines the characters that may not appear in a schema name and two integer types that define the maximum decimal precision and scale.
The following namespaces and types are used:
ICommandCapabilities cmdCapabilities = conn.CommandCapabilities;
int[] commands = cmdCapabilities.Commands;
Boolean supportsSelectDistinct = cmdCapabilities.SupportsSelectDistinct();
CommandType cmdType = (CommandType)commands[0];
Boolean supportsCreateDataStore = false;
for (int i = 0; i < commands.GetLength(0); i++) {
if (commands[i] == (int)CommandType.CommandType_CreateDataStore)
supportsCreateDataStore = true;
IConnectionCapabilities connCapabilities = conn.ConnectionCapabilities; LockType[] lockTypes = connCapabilities.LockTypes; SpatialContextExtentType[] spatialContextExtentTypes = connCapabilities.SpatialContextTypes; ThreadCapability threadCapability = connCapabilities.ThreadCapability; Boolean supportsConfiguration = connCapabilities.SupportsConfiguration();
IExpressionCapabilities exprCapabilities = connection.ExpressionCapabilities;
ExpressionType[] expressionTypes = exprCapabilities.ExpressionTypes;
FunctionDefinitionCollection functions = exprCapabilities.Functions;
FunctionDefinition function = functions[0];
ReadOnlySignatureDefinitionCollection signatureDefs = function.Signatures;
SignatureDefinition signatureDef = signatureDefs[0];
PropertyType returnPropertyType = signatureDef.ReturnPropertyType;
if (returnPropertyType == PropertyType.PropertyType_DataProperty)
{
DataType returnDataType = signatureDef.ReturnType;
}
ReadOnlyArgumentDefinitionCollection arguments = signatureDef.Arguments;
ArgumentDefinition argDef = arguments[0];
PropertyType argPropertyType = argDef.PropertyType;
if (argPropertyType == PropertyType.PropertyType_DataProperty)
{
DataType argDataType = argDef.DataType;
}
IFilterCapabilities filterCapabilities = conn.FilterCapabilities; Boolean supportsGeodesicDistance = filterCapabilities.SupportsGeodesicDistance(); ConditionType[] conditionTypes = filterCapabilities.ConditionTypes; DistanceOperations[] distanceOperations = filterCapabilities.DistanceOperations; SpatialOperations[] spatialOperations = filterCapabilities.SpatialOperations;
IGeometryCapabilities geometryCapabilities = conn.GeometryCapabilities; GeometryType[] geometryTypes = geometryCapabilities.GeometryTypes; GeometryComponentType[] geometryComponentTypes = geometryCapabilities.GeometryComponentTypes; int dimensionalities = geometryCapabilities.Dimensionalities; Boolean HasZ = (dimensionalities & 1) == 1; Boolean HasM = (dimensionalities & 2) == 2;
ISchemaCapabilities schemaCapabilities = conn.SchemaCapabilities; DataType[] dataTypes = schemaCapabilities.DataTypes; ClassType[] classTypes = schemaCapabilities.ClassTypes; string reservedCharactersForName = schemaCapabilities.ReservedCharactersForName; int maximumDecimalPrecision = schemaCapabilities.MaximumDecimalPrecision; DataType[] supportedAutoGeneratedTypes = schemaCapabilities.SupportedAutoGeneratedTypes; DataType[] supportedIdentityPropertyTypes = schemaCapabilities.SupportedIdentityPropertyTypes; Boolean supportsAutoIdGeneration = schemaCapabilities.SupportsAutoIdGeneration;