2013-09-30 33 views
0

一個存儲過程,我似乎不能,因爲我得到這個錯誤讀取到這個實體框架和使用LINQ:我如何使用,使用表與實體框架

The return types for the following stored procedures could not be detected. Set the return type for each stored procedure in the Properties window.

我試着用搜索引擎,但解決方案似乎從我的頭腦中走出來..任何方式我可以解決這個問題?絕望= [

我能想到使這項工作的唯一方法是創建一個新的表..但我只能用存儲過程不幸

ALTER PROCEDURE [dbo].[GetGame_FantasyHome] 
    -- Add the parameters for the stored procedure here 
    @GameDate varchar(8), 
    @TricodeHome varchar(3) 
AS 
BEGIN 
    -- SET NOCOUNT ON added to prevent extra result sets from 
    -- interfering with SELECT statements. 
    SET NOCOUNT ON; 

    CREATE TABLE #FantasyHome(
     GameKey int, 
     PlayerName varchar(50), 
     Tricode varchar(3), 
     StatString varchar(50), 
     Position varchar(20), 
     FantasyScore int 
    ) 

    DECLARE @gameKey int 
    SET @gameKey = (SELECT GameKey FROM Games WHERE [email protected] 
     AND [email protected]) 

    INSERT #FantasyHome 
    SELECT TOP 1 p.GameKey, p.PlayerName, p.Tricode, p.StatString, p.Position, 
     (p.Yards/25 + p.Touchdowns * 6 - p.Interceptions * 2) AS FantasyScore 
    FROM GamePassers AS p 
    WHERE [email protected] AND [email protected] 
    ORDER BY FantasyScore DESC, p.Yards DESC 

    SELECT * 
    FROM #FantasyHome 
    ORDER BY FantasyScore DESC 

    DROP TABLE #FantasyHome 
END 

回答

2

· The one way to get these types of stored procedures to work is to edit DBML by hand or write your own method signature for the procedure in a partial class To Handle multiple record set return from stored procedure by LINQ see the link here.

· The second way is to avoid using #temp Table in your stored procedure, instead of you can use Table type variable like below (@TempTable)

更多信息here。請務必閱讀該博客文章中指出的article about table variables in T-SQL

編輯: 檢查也解答了this SO question參考。

+0

謝謝你將會看到這個 – user1189352

+0

你是男人!把它變成表變量,它的工作!你認真地認真地爲我節省了數小時的工作時間,試圖找到一個解決方案 – user1189352

+0

下次記得開始尋找一個解決方案,通過搜索錯誤信息或只是其中的一部分,並檢查結果。 ;) –