SqlGeometryDataAdapter Class
The data adapter that allows generating map items from a geometry datasource.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v18.1.dll
Declaration
[LookupBindingProperties(null, "SpatialDataMember", null, null)]
[DataAccessMetadata("SQLDataSource", SupportedProcessingModes = "Simple", DataSourceProperty = "WizardSource", Platform = "Win", EnableDirectBinding = false)]
public class SqlGeometryDataAdapter :
SqlGeometryDataAdapterBase
Remarks
For more information about this data adapter, refer to the Load Vector Data from a SQL Geometry Field of the Data Table topic.
Example
To load data from a SQL Geometry data source, do the following.
- Create a SqlGeometryDataAdapter object.
- Specify its SqlGeometryDataAdapter.ConnectionString, SqlGeometryDataAdapter.SqlText and SqlGeometryDataAdapter.SpatialDataMember properties.
- Assign this object to the VectorItemsLayer.Data property.
Note
All data table field values loaded from the database will be provided as attributes for each SqlGeometryItem object generated using SqlGeometryDataAdapter.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-load-data-from-a-sql-geometry-data-source-t175898
const string filePath = "..\\..\\Data\\SQLG.mdf";
private void Form1_Load(object sender, System.EventArgs e) {
string fullFilePath = Path.GetFullPath(Path.Combine(Application.StartupPath, filePath));
SqlGeometryDataAdapter adapter = new SqlGeometryDataAdapter() {
ConnectionString = "Data Source=(local);AttachDbFileName=" + fullFilePath +
";Database=SqlGeometryDB;Integrated Security=True;MultipleActiveResultSets=True",
SqlText = "SELECT TOP 1000 [GeomCol1],[TextCol] FROM [dbo].[DemoTable]",
SpatialDataMember = "GeomCol1"
};
VectorItemsLayer layer = new VectorItemsLayer() {
Data = adapter,
ShapeTitlesPattern = "{TextCol}"
};
layer.DataLoaded += layer_DataLoaded;
mapControl1.Layers.Add(layer);
}
void layer_DataLoaded(object sender, DataLoadedEventArgs e) {
mapControl1.ZoomToFitLayerItems();
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SqlGeometryDataAdapter class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.