Interface IMapServerDataAccess
Provides access to the data source behind the MapServer.
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("A3072B50-65E2-4035-B438-8363EDD349C0")]
public interface IMapServerDataAccess
Methods
GetDataSource(string, int)
Get Data Source
object GetDataSource(string MapName, int LayerID)
Parameters
Returns
Remarks
This function allows fine-grained object access to a FeatureLayer, a RasterLayer or a StandaloneTable by returning IFeatureClass, IRaster or ITable respectively. If the layer or standalone table has any joins, the returned object will not contain the joined portion. In addition any field visibility or field alias set to the layer in the source map document will be ignored as it returns the underlying data source.
// Retrieve feature class workspace from a mapserver layer
private void AccessWrokspaceFromMapServiceLayer(IServerObject serverObject)
{
IMapServer mapService = (MapServer)serverObject;
IMapServerDataAccess mapServerDataAccess = (IMapServerDataAccess)serverObject;
// Get feature class from any layer
IFeatureClass featureClass = (IFeatureClass)mapServerDataAccess.GetDataSource(mapService.DefaultMapName, 0);
// Get the container feature dataset
IFeatureDataset featureDataset = featureClass.FeatureDataset;
// Get worksapces
IWorkspace workspace = featureDataset.Workspace;
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
}
GetDisplayDataSource(string, int)
Get Display Data Source
object GetDisplayDataSource(string MapName, int LayerOrTableID)
Parameters
Returns
Remarks
This function allows fine-grained object access to a FeatureLayer, a RasterLayer or a StandaloneTable by returning IFeatureClass, IRaster or ITable respectively, or IRelQueryTable when it is joined. In addition any field visibility or field alias set to the layer in the source map document will be ignored as it returns the underlying data source.
The main difference between GetDisplayDataSource and GetDataSouce functions is that the former one honors joins and returns IRelQueryTable when join exists. This IRelQueryTable interface gives you access to the source or destination table, or the relationship class. When the layer or standalone table is not participating in any join, the behavior of GetDisplayDataSource and GetDataSouce functions are identical.