Visual Studio 2008 + Sql 2008 CTP6 + Geography data type RRS feed

  • Question

  • Hi folks,

       when i try and drag my Sql2008 table from "Server Explorer" onto the linq designer ... it fails because i think it doesn't know about the GEOGRAPHY data type.


    Has anyone else noticed this? is there anything we can do about it?


    thanks Smile

    Monday, March 31, 2008 1:47 AM


  • AFAIK the desginer doesn't support UDT types (Geometry and Geography is implemented as UDTs)


    Monday, March 31, 2008 3:24 AM

All replies

  • AFAIK the desginer doesn't support UDT types (Geometry and Geography is implemented as UDTs)


    Monday, March 31, 2008 3:24 AM
  • Are there plans on having the designer 'know' about special Out Of the Box UDT's and then handle them?

    Is this the correct forum to ask this question?

    What are the alternatives?

    Gawd, i hope there will be a solution Sad Even if it ignores UDTs, but still generates the class, minis the UDT (and give a popup warning or something)...

    Monday, March 31, 2008 3:49 AM
  • Since this is not directly related to the geography and geometry types but is a general limitation with UDTs, I guess the right place is the Visual Studio forums.

    However, there is a workaround: Don't use the designer but write the linq expressions yourself. All you need to do is add a reference to the Microsoft.SqlServer.Types assembly (probably located in C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\Microsoft.SqlServer.Types.dll)

    Monday, March 31, 2008 3:54 AM
  • Hi Morton,

       wow - that is interesting! i never knew you could do that. Do you have any links to examples of using linq with Geography and/or Geometry? currently, i'm stuck with using linq + stored procedures (which is fine) but seeing it done with linq without having to use stored procedures would be hella sweet!

    Monday, March 31, 2008 4:19 AM

    Pure Krome, did you have any luck iwith this. I've tried what Morten described (manually editing the dbml file and using SqlGeography from Microsoft.SqlServer.Types but I just get casting errors. I'm not trying an approach where I create a computed column which exposes the geography value, but this is read only, so I think I'm going to have to use sprocs to write the objects


    If you managed to use geography with Linq to Sql in a less convoluted manner I'd love to hear how!



    Monday, June 30, 2008 11:06 AM
  • I'm curious too. Doing much more than construction and rendering of GEO* instances on the client side seems inefficient to me since you lose the value of indexing.



    Monday, June 30, 2008 4:00 PM
  •  tarmac321 wrote:


    Pure Krome, did you have any luck iwith this.


    Nope, i didn't give it a go. I'm using Stored Procedures to do all my Geospatial work (and loving it too!).

    Tuesday, July 1, 2008 12:07 AM
  • Has this been fixed? with vs2008  sp1
    Friday, May 8, 2009 4:39 AM
  • You can do this in a view or stored procedure, just include the column as:
    CAST(geography_column AS VARBINARY(MAX))..
    Ugh this cant be the answer?
    Friday, May 8, 2009 4:41 AM
  • Yeah mate, that's the answer (I believe).

    Make the field a VarBinary(MAX). if needs be, you can reference the sql spatial namespace and load it in as a WKB, I believe. That said, i've not tried it yet but i should be in a few weeks <-> 2 months (when i get some time to fix my R&D Database stuff i've been doing, at night after the bambino goes to sleep-ies).

    Has anyone else tried it?

    PS. Talk about cast "ressurect from dead" on thread :)
    -Pure Krome-
    • Edited by Pure Krome Friday, May 8, 2009 6:08 AM
    Friday, May 8, 2009 6:07 AM