我正在尝试将以下sproc添加到Entity Framework。通过“从模型更新”添加此项后,模型浏览器在模型的“函数导入”和“存储过程/函数”中显示此sproc。使用“函数导入”对话框中的“编辑”,我无法“获取列信息”并且无法确定集合的返回类型。
sproc的输出是一个临时表,但我确定要返回的列。这个问题是什么?我错过了设置EF的步骤吗?
ALTER PROCEDURE [dbo].[addrApproxSP]
-- Add the parameters for the stored procedure here
@frontage bigint = 0,
@housedir varchar(1) = 0,
@streetnum bigint = 0,
@streetdir varchar(1) = 0,
@distance bigint = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Set Variables
DECLARE @lowfront bigint,
@highfront bigint,
@lowstreet bigint,
@highstreet bigint,
@currname varchar(25),
@streetcur varchar(25),
@whereclause varchar(40),
@fixstreet varchar(25),
@pos int,
@piece varchar(500)
--Set variables to proper values in range
Set @lowfront = @frontage - @distance
set @highfront = @frontage + @distance
set @lowstreet = @streetnum - @distance
set @highstreet = @streetnum + @distance
-- Process for Street Names that are Numeric Values
-- Create Temp Table
CREATE TABLE #StreetNames
(streetname varchar(25))
-- SELECT StreetName and put in Temp table
INSERT #Streetnames(streetname)
select distinct streetname
from ADDR_STREETCOORD
where begincoord between @lowstreet and @highstreet
and STREETDIR = @streetdir
and lowhouse > @lowfront and HIGHHOUSE < @highfront
and HOUSEDIR = @housedir
union
select distinct streetname
from ADDR_STREETCOORD
where lowhouse > @lowstreet and HIGHHOUSE < @highstreet
and HOUSEDIR = @housedir
and begincoord between @lowfront and @highfront
and STREETDIR = @streetdir
-- Check each Streetname and those that are a coordinate (ex: "1000 S") change to "1000"
CREATE TABLE #FixStreets(streetname varchar(25))
DECLARE curStreet CURSOR FOR SELECT streetname FROM #StreetNames
OPEN curStreet
FETCH NEXT FROM curStreet INTO @fixstreet
WHILE @@FETCH_STATUS = 0
BEGIN
--insert code here
INSERT #FixStreets(streetname)
--Call Function to: parse the street name
--if the first part isnumeric then insert that
--if not numeric then keep as is
select [dbo].fnParseCoordinate(@fixstreet)
FETCH NEXT FROM curStreet INTO @fixstreet
END
CLOSE curStreet
DEALLOCATE curStreet
--select * from #FixStreets
--create a temp table to store the results of each street name in a single table
-- in order to return the results as a single table
--For Each street name search its frontage range values
--loop through each streetname to get the parcels matching those streets
CREATE TABLE #AllResults(Parcel varchar(14),Prop_locat varchar(50))
DECLARE curName CURSOR FOR SELECT streetname FROM #FixStreets
OPEN curName
FETCH NEXT FROM curName INTO @streetcur
WHILE @@FETCH_STATUS = 0
BEGIN
--insert code here
INSERT #AllResults(Parcel, Prop_locat)
select parcel_id,prop_locat
from ADDR_ParcelsWWW
where StreetName = @streetcur
and predir = @housedir
and housefrom between @lowfront and @highfront
union
select parcel_id,LOCATOR_ADDRESS
from ADDR_MASTERADDRESS
where StreetName = @streetcur
and predir = @housedir
and housefrom between @lowfront and @highfront
FETCH NEXT FROM curName INTO @streetcur
END
CLOSE curName
DEALLOCATE curName
--Select the results of all the tables
select Parcel, prop_locat from #AllResults
END
答案 0 :(得分:0)
当EF轮询您的SP时,它首先执行此操作:设置FMTONLY ON
如果您在SP中使用临时表,这可能会搞砸了,这看起来就像您正在做的那样。
尝试在SP的开头明确设置:设置FMTONLY OFF
这应该允许EF检测您的列。