调用接受用户定义表类型作为参数的表值函数

时间:2014-07-30 14:26:31

标签: c# sql-server entity-framework entity-framework-6

我们有以下TVF,带有TableType输入参数。我们已将函数和函数import添加到我们的edmx模型(数据库第一种方法)。当我们尝试使用dbContext.Function调用该函数时,唯一的输入参数是@radius。似乎实体框架没有认识到存在第二个输入参数(TableType)。最终我们希望将DataTable作为此参数传递。

CREATE FUNCTION [dbo].[fnWhatever] (
    @UserPOIList UserPOIListTableType READONLY,
    @Radius INT
)
RETURNS TABLE
AS
RETURN
    WITH AllZipsRanked
        AS (SELECT POI.UserPOIID
                   , Zip = ZipsWithinDistance.ZipCode
                   , ZipsWithinDistance.Distance
                   , RankZipDistance = ROW_NUMBER () OVER (PARTITION BY ZipsWithinDistance.ZipCode ORDER BY ZipsWithinDistance.Distance ASC) 
                           FROM dbo.UserPOI POI
                                JOIN @UserPOIList UserPOIIDs ON POI.UserPOIID = UserPOIIDs.UserPOIID 
                          CROSS APPLY mapping.fnGetZipsWithinDistanceLatLong (POI.LONGITUDE, POI.LATITUDE, @Radius) ZipsWithinDistance) 
        SELECT UserPOIID
             , Zip
             , Distance
               FROM AllZipsRanked
               WHERE RankZipDistance = 1

0 个答案:

没有答案
相关问题