如何使用Linq to SQL从存储过程中检索多行? [英] How to retrieve multiple rows from a stored procedure with Linq to SQL?
问题描述
我最近开始使用Linq to SQL,并想知道如何通过执行存储过程来获取多行,这是我想使用的一个简单sp:
I've recently started to work with Linq to SQL and wondered how to get multiple rows as a result of executing a stored procedure,here's a simple sp i want to work with:
CREATE PROCEDURE gsp_ftsmultiple
@SearchKey varchar(100)
AS
BEGIN
SET NOCOUNT ON;
SELECT Label, theContent
FROM FtsTest
WHERE FREETEXT( theContent, @SearchKey )
END
从Management Studio执行此sp很好,但是生成的上下文类中的相应方法返回一个int值,并且我不知道如何使用OUT参数尝试获取实际的行,但是它们只能返回一个结果.
Executing this sp from management studio is fine,but the corresponding method in the generated context class returns a int value, and I don't know how to get the actual rows, tried using the OUT parameters, but they can return only one result.
推荐答案
我认为您要做的就是创建一个与您的结果模式匹配的类,并确保dbml中的函数将其作为返回类型.
I think all you need to do is make a class that matches your result schema and make sure the function in the dbml has it as a return type.
请参见此处在msdn上
这篇关于如何使用Linq to SQL从存储过程中检索多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!