Q&A: How can I use LINQ with new data types in SQL Server 2008 such as the geospatial types?

This one has come up a few times. LINQ to SQL and LINQ to Entities in V1 do not currently support the newest types added to SQL Server 2008 nor do they support your own User Defined Types.

More specifically:

  • LINQ to SQL does not support the hierarchyID, geospatial, table or time types. UDTs are not supported. It does support the new DateTimeOffset , DateTime2, and Date types (NB: I have not tried this and I think it may require SP1)
  • LINQ to Entities does not support hierarchyID or geospatial. I haven’t yet checked the other new types but I believe they are also not supported. UDTs are not supported.

If you need to work with UDTs or the new types then you will either a) need to use traditional ADO.NET for those aspects of your application or b) lean on stored procedures to mask those types from L2S/L2E or c) do something creative.

An example of doing something creative is this post on working with geospatial via a DefiningQuery in the SSDL and some binary manipulation.

Comments (1)

  1. Session 1 ADO.NEXT – Entity Framework & Data Services Speaker: Eric Nelson http://blogs.msdn.com/ericnel

Skip to main content