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 ...
随机推荐
- 第二步:开发工具Eclipse安装并汉化
打开下载官网:www.eclipse.org.点击下载(download英文)然后就是安装步骤了,还是一样一直的点击下一步,默认安装到C盘.如下图: 汉化步骤: 1.打开www.eclipse.org ...
- 网易 监控 openstack
http://www.360doc.com/content/16/0416/08/13792507_551022987.shtml
- Codeforces Beta Round #4 (Div. 2 Only) A. Watermelon【暴力/数学/只有偶数才能分解为两个偶数】
time limit per test 1 second memory limit per test 64 megabytes input standard input output standard ...
- 10.28 HTML DOM
- 「Codeforces Round #441」 Classroom Watch
Discription Eighth-grader Vova is on duty today in the class. After classes, he went into the office ...
- delphi 浮点数float转换成十六进制字符串的方法(FloatToHex)
重新书写了float型转为十六进制的delphi程序 Function FloatToHex(Value: single): string; var l, i: integer; HexText,te ...
- NAND Flash memory in embedded systems
参考:http://www.design-reuse.com/articles/24503/nand-flash-memory-embedded-systems.html Abstract : Thi ...
- JAVA生成问答式验证码图片,支持加减算法
原文:http://liuguihua0823.iteye.com/blog/1511355 import java.awt.Color; import java.awt.Font; import j ...
- Android API level 与version对应关系
https://www.cnblogs.com/jinglecode/p/7753107.html Platform Version API Level VERSION_CODE 中文名称 Andro ...
- Linux操作系统实时性分析
1. 概述 选择一个合适的嵌入式操作系统,可以考虑以下几个因素: 第一是应用.如果你想开发的嵌入式设备是一个和网络应用密切相关或者就是一个网络设备,那么你应该选择用嵌入式Linux或者uCLinux ...