locked
Using GEOGRAPHY type and Entity Framework RRS feed

  • Question

  • I have seen some folks try to represent the GEOMETRY type as a varbinary (in pulling from the type) to enable read/write of the type data via Entity Frammework. I want to know a few things about using GEOMETRY or GEOGRAPHY with Entity Framework.

    - Does anyone know when EF will be able to support UDT types? That might help.

    - Who has tried what approaches for storaing the geospatial types and then retrieving, inserting, and updating them via Entity Framework?

    - Does anyone know when/what else will support the geospatial types fairly natively (for example ADO or .NET 3.5).

    We would love to use these types in the app I am working on now but need to have the ability to use them with Entity Framework. One idea I had was to use the CRUD procedure layer to obfuscate and then go native at a later time when it was feasible.

    Thanks Much,

    Brent Van Allen
    Datasource
    Tuesday, January 6, 2009 9:54 PM

Answers

  • The only way to use it is to make it a binary representation and convert it to a usable type at the client.

    -Jens K. Suessmeyer
    Tuesday, January 6, 2009 10:45 PM

All replies

  • The only way to use it is to make it a binary representation and convert it to a usable type at the client.

    -Jens K. Suessmeyer
    Tuesday, January 6, 2009 10:45 PM
  • Bummer
    Tuesday, January 6, 2009 11:07 PM
  • Erm, come on how can this be an answer? except a very curt, short one. ;-)

    He had several questions...

    <quote>
    - Does anyone know when EF will be able to support UDT types? That might help.

    - Who has tried what approaches for storaing the geospatial types and then retrieving, inserting, and updating them via Entity Framework?

    - Does anyone know when/what else will support the geospatial types fairly natively (for example ADO or .NET 3.5).
    </quote>

    Something on when EF will support UDT, noticed on http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/b0ac34d7-91de-4af9-8064-af4625fd6a25/

    • Edited by Steve Casey Thursday, July 9, 2009 10:06 AM
    Thursday, July 9, 2009 10:04 AM
  • In answer to the final question:- the spatial datatypes are already supported by .NET 3.5, since that is actually their native format anyway. Geometry, geography, and hierarchy datatypes are all CLR system datatypes in SQL Server 2008, defined in Microsoft.SqlServer.Types.dll.
    If you import this assembly into your own .NET project, you can use SqlGeography and SqlGeometry types and methods on the client side just as you would in the database.
    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Thursday, July 9, 2009 10:45 AM
    Answerer