Chain LINQ IQueryable, and end with Stored Procedure

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-05-24T17:53:08Z Indexed on 2010/05/24 18:01 UTC
Read the original article Hit count: 325

Filed under:
|
|
|

I'm chaining search criteria in my application through IQueryable extension methods, e.g.:

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?

I'm envisioning something like .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).

Is something like this possible? Sample code?

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ