How to use SQL Views with King.MsSqlSpatial

This page describes how to setup provider to use SQL Views in MapGuide,  Autodesk MAP.
King.MsSqlSpatial is using additional table in database to describe SQL Views.
Each row in this table represents one FDO Class based on one SQL View.
Name of table is defined in "KingFdoClass" connection property.
You can create table and add rows with sql or you can use Fdo2Fdo.

With Fdo2Fdo you can create an "KingFdoClass" Table and you can add FDO Class based on SQL View.

For purpose of this example I will assume that in SQL Database there is a table with geometry call Redding_Parcels and there is also Redding_View - SQL View based on Redding_Parcels geometry table.

  1. Run Fdo2Fdo
  2. Create new connection to MS SQL Server and enter name of table in "KingFdoClass" connection property (e.g FdoClass ).
    In this moment table doesn't exist yet.
  3. In Fdo2Fdo Select Dialog MS SQL Server Toolbox -> KingFdoClass
  4. Click on button "Create KingFdoClass Table"
    New table will be created (e.g. FdoClass)
  5. Click "Add..."
  6. Enter fields in dialog like:
    FDO Schema, FDO Class Name - enter any names you want for new FDO Class
    Schema, Name - enter schema name and name of the SQL View you want to query ( e.g. Readding_View )
    Geometry Column - enter name of geometry column "Geometry"
    Geometry Table Schema, Table Name - enter name of geometry table (e.g. Redding_Parcels)

    Screenshot example

  7. Click OK
  8. Use Fdo2Fdo FDO Source Toolbox - FDO Schema to check that new class exists
  9. Because of caching you need to restart MapGuide Server to see new FDO Class
     

Note:

King.MsSqlSpatial will query against SQL View and spatial filter will be run against geometry table.
In order to work you need to include Geometry Column and identity column of geometry table into SQL View.