IQueryable for Subsonic Stored Procedure
I need to use stored procedure to get data from DB, but I would also like to use IQueryable to add some filtering to results. I'm using subsonic and for now can't see a way to use subsonic sp and IQueryable. The only idea I have is to make a view that will perform all required joins. Then perform call to view like to table with subsonic:
MyView.All()
Subsonic All returns IQu开发者_StackOverflow社区eryable and instead of adding where in sp I can add filter clauses in code. Not sure if this is viable solution or not?
IQueryable
allows translating LINQ queries into SQL statements. Using IQueryable
in conjunction with stored procedures is the same as mixing a SQL statement with a stored procedure, such as SELECT * FROM dbo.MyStoredProc WHERE x > 100
. Since this won't work, mixing IQueryable
with a stored procedure is useless, because there is no way to filter the results of the SP before they return.
What you are looking for is client-side (.NET side) filtering. For this you can simply use IEnumerable
. When your stored procedure returns a collection of items, you can still use LINQ queries over that collection.
Ok, I`ve finished with this solution to add views to my SubSonic objects and IQueryable to add filtering.
精彩评论