我在 MSSQL 2005 中创建了一个函数,我想使用 linq 运行这个函数。我的函数有 2 个参数。定义如下:
USE [MobileGateway]
GO
/****** Object: UserDefinedFunction [dbo].[Fn_GetNoLocationAddress] Script Date: 11/07/2012 08:27:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[Fn_GetNoLocationAddress]
(
-- Add the parameters for the function here
@Site nvarchar(255),
@ReceivedDate int
)
RETURNS @noLocationAddress TABLE (
RequestID int NOT NULL,
Barcode varchar(50) NOT NULL,
AdrID int NOT NULL,
Name varchar(50) NOT NULL,
Street varchar(50) NOT NULL,
HouseNo varchar(4) NOT NULL,
Postal varchar(8) NOT NULL,
City varchar(50) NOT NULL,
Country varchar(50) NOT NULL,
Latitude varchar(50) NOT NULL,
Longitude varchar(50) NOT NULL,
ReveivedDate datetime NOT NULL
)
AS
BEGIN
-- Add the SELECT statement with parameter references here
INSERT INTO @noLocationAddress
SELECT TOP (100) PERCENT Request1.RequestID, TrackIT.dbo.Sending.Barcode, TrackIT.dbo.Address_View.AdrID, TrackIT.dbo.Address_View.Name,
TrackIT.dbo.Address_View.Street, TrackIT.dbo.Address_View.HouseNo, TrackIT.dbo.Address_View.Postal, TrackIT.dbo.Address_View.City,
TrackIT.dbo.Address_View.Country, Request1.Latitude, Request1.Longitude, Request1.ReceivedDate
FROM (SELECT DISTINCT RequestID, LTRIM([Content]) AS Barcode, Latitude, Longitude, ReceivedDate
FROM dbo.RequestWithLocation
WHERE (Site LIKE @Site) AND ([Content] <> '') AND (AddressID = '0') AND (ReceivedDate > DATEADD(day, -@ReceivedDate, GETDATE()))) AS Request1 INNER JOIN
TrackIT.dbo.Sending ON Request1.Barcode = TrackIT.dbo.Sending.Barcode INNER JOIN
TrackIT.dbo.Address_View ON TrackIT.dbo.Sending.DeliveryAdrID = TrackIT.dbo.Address_View.AdrID
ORDER BY TrackIT.dbo.Address_View.AdrID
RETURN
END
如您所见,我有 2 个参数,并且正在返回一个包含信息的表格。但是我需要使用 linq 来执行这个函数。任何人都可以帮忙吗?谢谢