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://riteshkk2000.blogspot.com.au/2010/08/error-unknown-return-type-return-types.html
The return types for the following stored procedures could not be detected的更多相关文章
- [MySQL] Stored Procedures 【转载】
Stored routines (procedures and functions) can be particularly useful in certain situations: When mu ...
- Good Practices to Write Stored Procedures in SQL Server
Reference to: http://www.c-sharpcorner.com/UploadFile/skumaar_mca/good-practices-to-write-the-stored ...
- An Introduction to Stored Procedures in MySQL 5
https://code.tutsplus.com/articles/an-introduction-to-stored-procedures-in-mysql-5--net-17843 MySQL ...
- Cursors in MySQL Stored Procedures
https://www.sitepoint.com/cursors-mysql-stored-procedures/ After my previous article on Stored Proce ...
- MySQL Error Handling in Stored Procedures 2
Summary: this tutorial shows you how to use MySQL handler to handle exceptions or errors encountered ...
- Why Stored Procedures?
http://www.w3resource.com/mysql/mysql-procedure.php Stored procedures are fast. MySQL server takes s ...
- Part 10 Stored procedures in sql server
Stored procedures in sql server Stored procedures with output parameters Stored procedure output par ...
- [转]Oracle Stored Procedures Hello World Examples
本文转自:http://www.mkyong.com/oracle/oracle-stored-procedures-hello-world-examples/ List of quick examp ...
- [转]How to: Execute Oracle Stored Procedures Returning RefCursors
本文转自:http://www.telerik.com/help/openaccess-orm/openaccess-tasks-oracle-execute-sp-result-set.html I ...
随机推荐
- 关于多态的理解,有助于理解TStream抽象类的多态机制。
有的时候 不是很明白流的机制,因为有内存流 文件流 图片流 等等 他们之间的相互转化 靠的就是流的多态性.... unit Unit11; interface uses Winapi.Windows ...
- 获取a'p'p签名
1.第一种方式 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list& ...
- 我从16ASPX上下了一个程序在运行时出错是怎么回事?运行时出现用户SA登陆失败,但是我已经把数据库导入SQL
如果你账号密码正确,那你可能没有打开你的管线服务,或者没有配置好你的客户端
- React Native解决Android的WebView无法执行injectedJavaScript代码
需求 在用WebView组件写一个东西,要求功能:打开web后进行js代码注入. 开发 代码很简单,示例: const js = ` alert(1); alert(2); `; <WebVie ...
- Codeforces Round #306 (Div. 2) A. Two Substrings【字符串/判断所给的字符串中是否包含不重叠的“BA” “AB”两个字符串】
A. Two Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- luogu P1340 兽径管理
题目描述 约翰农场的牛群希望能够在 N 个(1<=N<=200) 草地之间任意移动.草地的编号由 1到 N.草地之间有树林隔开.牛群希望能够选择草地间的路径,使牛群能够从任一 片草地移动到 ...
- List集合-保存和输出宠物信息
package collection; /** * 宠物类 * @author * */ public class Pet { private String name; private String ...
- 每天一个liunx命令10之nohup和xargs
1上传jar包到服务器/edgewalk/springboot/下 2编写启动脚本start.sh #!/bin/sh APP_HOME=/edgewalk/springboot cd $APP_HO ...
- 【Linux】linux下查看目录所在分区
命令如下: df -h 目录名 具体使用例子如下:查看/home/sxd/文档处于哪个分区 ------------------------------------------------------ ...
- 能上架App的GooglePlay开发者账号获取流程
googleplay 开发者账号申请流程 接到公司号召,要让我们的app走向世界,上架GooglePlay,都说天朝的Android 程序员是折翼的天使,猛然发现写了做么多年的Android,竟然不知 ...