Here's the location usage in NerdDinner sample that we could modify with the geography data type as per the previous post:
public IQueryable<Dinner> FindByLocation(float latitude, float longitude)
{
var dinners = from dinner in FindUpcomingDinners()
join i in NearestDinners(latitude, longitude)
on dinner.DinnerID equals i.DinnerID
select dinner;
return dinners;
}
/****** Object: UserDefinedFunction [dbo].[NearestDinners] Script Date: 7/30/2013 7:39:11 AM ******/
DROP FUNCTION [dbo].[NearestDinners]
GO
/****** Object: UserDefinedFunction [dbo].[NearestDinners] Script Date: 7/30/2013 7:39:11 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[NearestDinners]
(
@lat real,
@long real
)
RETURNS TABLE
AS
RETURN
SELECT Dinners.DinnerID
FROM Dinners
WHERE dbo.DistanceBetween(@lat, @long, Latitude, Longitude) <100
GO
public IQueryable<Dinner> FindByLocation(float latitude, float longitude)
{
var dinners = from dinner in FindUpcomingDinners()
join i in NearestDinners(latitude, longitude)
on dinner.DinnerID equals i.DinnerID
select dinner;
return dinners;
}
DROP FUNCTION [dbo].[NearestDinners]
GO
/****** Object: UserDefinedFunction [dbo].[NearestDinners] Script Date: 7/30/2013 7:39:11 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[NearestDinners]
(
@lat real,
@long real
)
RETURNS TABLE
AS
RETURN
SELECT Dinners.DinnerID
FROM Dinners
WHERE dbo.DistanceBetween(@lat, @long, Latitude, Longitude) <100
GO
No comments:
Post a Comment