我可以像在 .dbml 中那样向 .edmx 文件添加 SQL 函数吗?如果可以的话,我该怎么做?如果我不能,有什么解决方法吗?
我尝试谷歌,但找不到任何关于如何做到这一点的具体答案。
根据给定的答案,我创建了一个存储过程并尝试添加“导入函数”,但它说“存储过程不返回任何列”。我哪里做错了?
功能:
ALTER FUNCTION [dbo].[fn_locationSearch](@keyword varchar(10))
RETURNS TABLE
AS
RETURN
(
SELECT CustomerBranch.ID,CustomerBranch.BranchName,CustomerBranch.Longitude,CustomerBranch.Latitue,CustomerBranch.Telephone,CustomerBranch.CategoryID,CustomerBranch.Description
FROM FREETEXTTABLE (CustomerOffer,*,@keyword) abc INNER JOIN OffersInBranch
ON abc.[key]=OffersInBranch.OfferID INNER JOIN CustomerBranch ON OffersInBranch.BranchID=CustomerBranch.ID
UNION
SELECT CustomerBranch.ID,CustomerBranch.BranchName,CustomerBranch.Longitude,CustomerBranch.Latitude,CustomerBranch.Telephone,CustomerBranch.CategoryID,CustomerBranch.Description
FROM CustomerBranch WHERE FREETEXT(*,@keyword)
)
存储过程:
ALTER PROCEDURE USP_locationSearch
(@keyword varchar(10))
AS
BEGIN
SELECT * from dbo.fn_locationSearch(@keyword)
END