日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

The return types for the following stored procedures could not be detected

發布時間:2023/12/10 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The return types for the following stored procedures could not be detected 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、使用dbml映射數據庫,添加存儲過程到dbml文件時報錯。

2、原因:存儲過程中使用了臨時表

3、解決方案

3.1?通過自定義表值變量實現

Ex:

DECLARE @TempTable TABLE

(

AttributeID INT,

Value NVARCHAR(200)

)

INSERT INTO @TempTable Select * from Attribute

OR

--Execute SP and insert results into @TempTable

INSERT INTO @TempTable Exec GetAttribute @Id

You can do all operation which you was doing with #Temp table like Join, Insert, Select etc.

3.2??選中Db.dmbl文件--右鍵--新建--class文件--名稱Db.cs,自定義partial class Db,寫獲取數據的方法,其中MyModel為你需要返回的數據model,Id為存儲過程輸入參數,存儲過程名稱為GetDataById(原名為[GetProjectsByClientId])

?

public partial class Db {[global::System.Data.Linq.Mapping.FunctionAttribute(Name = "dbo.GetDataById")]public ISingleResult<MyModel> GetProjectsByClientId([global::System.Data.Linq.Mapping.ParameterAttribute(DbType = "NVarChar(10)")] string Id){IExecuteResult result = this.ExecuteMethodCall(this, ((System.Reflection.MethodInfo)(System.Reflection.MethodInfo.GetCurrentMethod())), Id);return ((ISingleResult<MyModel>)(result.ReturnValue));}}

?

調用:?IList<MyModel> lst = db.GetDataById(id).ToList();

4、存儲過程(進行了簡化,理解意思即可)


IF object_id('GetDataById') IS NOT NULL
DROP PROCEDURE [dbo].[GetDataById]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create procedure [dbo].[GetDataById]
?@clientId nvarchar(10)
?as
?begin
? SET NOCOUNT ON;
? IF object_id('tempdb..##tempProject') IS NOT NULL
?? ??? ?DROP TABLE ##tempProject
?? ?
? select * into ##tempProject from Project where ClientId=@ClientId
? select p.id as ID,p.Name,a.Code,b.dtDate
????? ??? ?from ##tempProject p
?? ??? ?left join [dbo].[A] a on p.Id=a.ProjectId
?? ??? ?left join [dbo].[B] b on b.ProjectId=a.ProjectId
?? ??? ?
?end
GO

參考:

http://stackoverflow.com/questions/7035669/the-return-types-for-the-following-stored-procedures-could-not-be-detected

http://riteshkk2000.blogspot.com.au/2010/08/error-unknown-return-type-return-types.html

http://beyondrelational.com/modules/2/blogs/45/posts/12025/how-to-get-multiple-result-set-of-procedure-using-linq-to-sql.aspx

轉載于:https://www.cnblogs.com/xiaochun126/p/4691529.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的The return types for the following stored procedures could not be detected的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。