简体   繁体   中英

Linq to sql unkown return types stored procedure .dbml

ALTER PROCEDURE [dbo].[uspGetBusesByDepature] 
    -- Add the parameters for the stored procedure here
    @vRouteNumber varchar(4),
    @dtDepartureTime datetime,
    @dtArrivalTime datetime,
    @InDate datetime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @DeparturePoint geography,
        @Latitude float,
        @Longitude float,
        @Radius float

-- Insert statements for procedure here
SET @Latitude = (SELECT fRouteWayPointLatitude 
                 FROM dbo.RouteWayPoint 
                 WHERE vRouteNumber = @vRouteNumber 
                        AND iSequence = 1)

SET @Longitude = (SELECT fRouteWayPointLongitude
                 FROM dbo.RouteWayPoint 
                 WHERE vRouteNumber = @vRouteNumber 
                        AND iSequence = 1)

SET @Radius = (SELECT fRouteWayPointRadius
                 FROM dbo.RouteWayPoint 
                 WHERE vRouteNumber = @vRouteNumber 
                        AND iSequence = 1) * 1000

SET @DeparturePoint = geography::Point(@Latitude, @Longitude, 4326)
SET @dtDepartureTime = CONVERT(varchar, @InDate, 101) + ' ' + CONVERT(varchar(8), @dtDepartureTime, 108)

SELECT gps.iVehicleID, sDesc AS vVehicleDescription, sRegNo AS [vVehicleRegNo], 
         SUBSTRING(CONVERT(varchar(8), MIN(dtTime), 108), 1, 5) 
         + ' | ' + SUBSTRING(sDesc, 1, 4) + ' - ' + 
         SUBSTRING(sRegNo, 1, CHARINDEX('-',sRegNo,1)-1) 
        AS vVehicleText, MIN(dtTime) AS dtTime--, 
        --dbo.fnBusIsAssigned(gps.iVehicleID, @dtDepartureTime, @dtArrivalTime, @InDate) AS isAssigned
FROM dbo.GPSDataDW gps INNER JOIN Vehicles v
ON gps.iVehicleID = v.iVehicleID
WHERE dtTime BETWEEN  DATEADD(MI, -30, @dtDepartureTime) AND DATEADD(MI, 30, @dtDepartureTime) 
    AND @Radius >  @DeparturePoint.STDistance(geography::Point(fLatitude, fLongitude, 4326))
GROUP BY gps.iVehicleID, sDesc, sRegNo

END

Any one who can help me with this error I check everything I don't seem to be calling/returning multiple table at once.

Thanks in advance.

Good day,

I found my problem. The problem was the geography data type which was causing this problem. After I commented this line out:-

SET @DeparturePoint = geography::Point(@Latitude, @Longitude, 4326);

everything went well, I don't know why is that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM