[英]Chain LINQ IQueryable, and end with Stored Procedure
I'm chaining search criteria in my application through IQueryable extension methods, eg: 我通过IQueryable扩展方法在应用程序中链接搜索条件,例如:
public static IQueryable<Fish> AtAge (this IQueryable<Fish> fish, Int32 age)
{
return fish.Where(f => f.Age == age);
}
However, I also have a full text search stored procedure: 但是,我也有一个全文本搜索存储过程:
CREATE PROCEDURE [dbo].[Fishes_FullTextSearch]
@searchtext nvarchar(4000),
@limitcount int
AS
SELECT Fishes.* FROM Fishes
INNER JOIN CONTAINSTABLE(Fishes, *, @searchtext, @limitcount)
AS KEY_TBL ON Fishes.Id = KEY_TBL.[KEY]
ORDER BY KEY_TBL.[Rank]
The stored procedure obviously doesn't return IQueryable, however, is it possible to somehow limit the result set for the stored procedure using IQueryable's? 该存储过程显然不会返回IQueryable,但是,是否有可能使用IQueryable的方式以某种方式限制该存储过程的结果集?
I'm envisioning something like .AtAge(5).AboveWeight(100).Fishes_FulltextSearch("abc"). 我正在设想类似.AtAge(5).AboveWeight(100).Fishes_FulltextSearch(“ abc”)之类的东西。
In this case, the fulltext search should execute on a smaller subset of my Fishes table (narrowed by Age and Weight). 在这种情况下,全文搜索应在我的Fishes表的较小子集上执行(按年龄和体重缩小)。
Is something like this possible? 这样的事情可能吗? Sample code?
样例代码?
I think that it might work if you 我认为如果您
Fishes_FulltextSearch("abc")
Fishes_FulltextSearch("abc")
创建另一个扩展方法 Hope this helps. 希望这可以帮助。
如果可以在视图中使用ContainsTable,则-that-返回IQueryable ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.