可以,前段时间用过,给你举个例子 ///一般存储过程 var users = db.proc_GetAllUser();//linq调用存储过程 var a = (from u in db.proc_GetAllUser() where u.LoginId.StartsWith("x") select u).ToList(); /** * linq调用带输入输出参数的存储过程 Create proc dbo.proc_spWithParam * @customerId nchar(5) * @rowcount int output * as * set nocount on * set @rowcount =(select count(*) from customer where customerId=@customerId) * * 后台调用 * private ExamDBDataContext db = new ExamDBDataContext(); * db.proc_spWithParam("a",ref rowcount)
http://msdn.microsoft.com/zh-cn/netframework/aa904594.aspx
///一般存储过程
var users = db.proc_GetAllUser();//linq调用存储过程
var a = (from u in db.proc_GetAllUser()
where u.LoginId.StartsWith("x")
select u).ToList(); /**
* linq调用带输入输出参数的存储过程
Create proc dbo.proc_spWithParam
* @customerId nchar(5)
* @rowcount int output
* as
* set nocount on
* set @rowcount =(select count(*) from customer where customerId=@customerId)
*
* 后台调用
* private ExamDBDataContext db = new ExamDBDataContext();
* db.proc_spWithParam("a",ref rowcount)
*/
//绑定
this.GridView1.DataSource = a;
this.GridView1.DataBind();
学Linq to sql:存储过程