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 ...
随机推荐
- log4j配置文件动态指定日志文件名称
我们在项目当中经常会使用log4j进行日志记录,偶尔会遇到一些要求,比如日志文件名称按照启动参数动态配置,而不去修改log4j.xml,比较简单的一种做法是,通过设置系统属性的方式实现,代码: if( ...
- Java进阶之路,技术要点
宏观方面 一.JAVA.要想成为JAVA(高级)工程师肯定要学习JAVA.一般的程序员或许只需知道一些JAVA的语法结构就可以应付了.但要成为JAVA(高级)工程师,您要对JAVA做比较深入的研究.您 ...
- yum安装jdk环境变量配置
系统版本 [root@localhost ~]# cat /etc/redhat-release CentOS Linux release (Core) #安装之前先查看一下有无系统自带jdk rpm ...
- windows下phpstorm的常用快捷键及使用技巧
1.pubf+回车 声明一个方法 2./ ** 回车 生成注释 3.Ctrl +g 跳转行 4.Ctrl + Alt + L 代码格式化 5.Ctrl +D 复制当前行到下一行 6.Ctrl ...
- css伪类元素:after 的多功能用法——任意大小的底边框
需求用法出现的背景: 由于项目UI的优化,项目中所有tab导航选中的状态都是统一样式书写的,之前都是用的border-bottom,新的需求如果用以前的本办法就是定位一个选中边框在底部,但是涉及的模板 ...
- FZU-2216 The Longest Straight(尺取法)
Problem 2216 The Longest Straight Accept: 523 Submit: 1663Time Limit: 1000 mSec Memory Limit ...
- poj2728(最小比率生成树)
poj2728 题意 给出 n 个点的坐标和它的高度,求一颗生成树使得树上所连边的两点高度差之和除以距离之和最小. 分析 01分数规划+最小生成树. 对于所有的边,在求最小生成树过程中有选或不选的问题 ...
- 1,java的跨平台原理
简单讲一下java的跨平台原理: (1)为什么跨平台: 由于各OS支持的指令集各不相同,就需要程序在不同的平台执行不同的代码 (2)JAVA是如何实现的: ava开发了适合不同的OS及不同位数的jav ...
- VisualStudio Shell简介 — 界面定制
项目组成 首先我们来看一下模板自动生成的工程文件: 它包括两个C++工程和两个C#工程,首先我们来看两个C++的工程: VSShellStub1, 这个是系统的启动项,它是最终的exe文件的 ...
- linux之rpm指令
rmp原本是Red Hat Linux发行版专门用来管理Linux各项套件的程序,由于它遵循GPL规则且功能强大方便,因而广受欢迎.逐渐受到其他发行版的采用.RPM套件管理方式的出现,让Linux易于 ...