Last post Sep 21, 2014 10:42 AM by ThatsIT
Sep 20, 2014 08:57 AM|ThatsIT|LINK
I have a stored procedure
ALTER PROCEDURE [dbo].[Distance] (@Lat1 as float,
@Long1 as float, @Lat2 as float, @Long2 as float)
select ([dbo].[DistanceBetween](@Lat1,@Long1,@Lat2,@Long2)) as Distance
That uses a function to return the distance between 2 sets of longitude and latitude. I have imported it into my Entity model, I have tested it, it all works fine, but I want to use it in a linq query like
Dim locationsx As IEnumerable(Of EF.Location) = db.Locations.
Where(Function(w) db.Distance(location.Lat, location.Lon, w.Lat, w.Lon).Average > searchCriteria.Kms).ToList
but it returns a nullable that causes an error, how can I get around this, can I force it to return a double?
Sep 21, 2014 09:06 AM|wmec|LINK
Sep 21, 2014 10:42 AM|ThatsIT|LINK
I don't think I explained or even understood my problem when posting.
What it comes down too, is I expected that after importing SP into EF, I would be able to use it in within my linq queries, but I don't think I can, it always gives the error, that it cannot convert to stored procedure.
I solved the problem by moving all the logic into the SP this means I have to create a new SP for slightly different queries.