1.普通存储过程

如数据库有如下存储过程

create proc sp_singleresultset

as

set nocount on

select * from customers 

然后在IDE服务资源管理器中拖入到dbml中,保存,它就会生成sp_singleresultset的方法,
方法如下:
Code

他会自动返回存储过返回的东西。
Linq to Object 代码

var 单结果集存储过程 =
            
from c in ctx.sp_singleresultset()
           
            select c;

这样就得到了存储过程返回的结果集了

2.带参数的存储过程

  
创建如下存储过程:
create proc [dbo].[sp_withparameter]
@customerid nchar(5),
@rowcount int output
as
set nocount on
set @rowcount = (select count(*from customers where customerid = @customerid)

执行
Code

3.多结果集的存储过程


创建一个多结果集的存储过程

create proc [dbo].[sp_multiresultset]
as
set nocount on
select * from customers
select * from employees

找到生成的存储过程方法:
Code
修改为:
Code

代码测试:

 

Code

 

posted on 2009-10-16 15:16  YangBayker  阅读(991)  评论(0编辑  收藏  举报