Using Geography data type in LinqPad and struggling a bit...

edited May 2012
Hi guys. I have the following query and it's not working. I've imported the Microsoft.SqlServer.Types into the query and got it to work on some things. I believe this is a problem related to the sql/expression tree part of it, but maybe not. The calculations locally work fine and the type is displayed in all the dumps just fine.
Microsoft.SqlServer.Types.SqlGeography mySpot = Microsoft.SqlServer.Types.SqlGeography.Point(39.936889304163117, -86.279353415939212, 4326);
var query = from p in Providers
join l in Locations.Where (x => (mySpot.STDistance(x.GeoPoint) > 1000))
on p.Id equals l.ProviderID
into ProviderLocations
select new {prov=p, ProviderLocations};
I get this error:
Cannot convert lambda expression to delegate type 'System.Func<LINQPad.User.Locations,bool>' 
because some of the return types in the block are not implicitly convertible to the delegate return type

Cannot implicitly convert type 'System.Data.SqlTypes.SqlBoolean' to 'bool'. 
An explicit conversion exists (are you missing a cast?)
I thought I'd ask. I tried rewriting the query to use a stored procedure for the part that I couldn't get to work, but that failed too as it couldn't infer the proper type.

If this looks a lot like the example on page 392 of the C# book, don't be surprised. :) Awesome book and even more awesome product. First go with C# and this book has been the greatest help of all.

All the pure SQL stuff in SSMS work fine. I was just trying really hard to get this into Linq. I think there are subqueries that will benefit from Linq a LOT.

Thanks in advance.


Sign In or Register to comment.