将存储过程与linq一起使用到SQL [英] Use stored procedure with linq to sql

查看:71
本文介绍了将存储过程与linq一起使用到SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下存储过程,但我不知道如何将它与Linq to Sql一起使用.

我将常规存储过程与Linq to Sql一起使用,但是此存储过程基于两个表检索数据.
如何使用Linq to Sql做到这一点?
请帮我.提前谢谢.

Hi I use the following stored procedure, but i do not know how i can use this with Linq to Sql.

I use the normal stored procedure with Linq to Sql, but this stored procedure retrieves data based on two tables.
How can I do this with Linq to Sql?
Please help me. Thanks in advance.

ALTER PROCEDURE dbo.PackageTestForPerform
        (
        @Package_ID int,
        @Patient_ID nvarchar(50)
        )
        
AS
select t.dep_name,t.test_name,t.sub_test_name,
CASE WHEN 
ISNULL((
        SELECT COUNT(*) 
        from Patient_Package_Test p
        where patient_Id=@Patient_ID and p.test_code=t.test_code and p.Sub_Test_id=t.Sub_Test_code
),0)>0 THEN 'TRUE' ELSE 'FALSE' END AS [Status]
from packagetest t 
where package_ID=@Package_ID

推荐答案

用作

use as

[System.Data.Linq.Mapping.Function(Name = "[TRNS].[Get_PRGoods]")]
       public System.Data.Linq.ISingleResult<PRGood> GetPRGoodsDetails(int PickupID)
       {
           System.Data.Linq.IExecuteResult result = this.ExecuteMethodCall(this, ((System.Reflection.MethodInfo)(System.Reflection.MethodInfo.GetCurrentMethod())), PickupID);
           return ((System.Data.Linq.ISingleResult<PRGood>)(result.ReturnValue));
       }


hiii,请参阅本文

http: //weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx [
hiii,refer this article

http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx[^]


这篇关于将存储过程与linq一起使用到SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆