EF using skip and take on stored procedure
c#, entity-framework, sql, stored-procedures
Solution
I did encounter such requirements before. Originally, my option was to use stored procedure, but when I realize that data could be thousands, using SP no longer became applicable. Here are the two things I did to do this:
- I created a view where the result of SP is there. Of course, this contains all the records without filter yet. I used that view to manipulate the records via EF where Take and Skip is alreay applicable.
- I stick to SP. What I did is to design the SP to allow receiving Take and Skip Count. I created the SP as string the use sp_executesql.
Problem
How does `Skip()` and `Take()` work in Entity Framework when calling a stored procedure? I can't access sql profiler to check, but I want to make sure I optimize the amount of data sent between servers. Say I have the following code, where `MyStoredProcedure` returns 1000+ rows. ``` List<MyComplex_Result> myComplexList = db.MyStoredProcedure() .Skip(50) .Take(10); ``` Will the `Take(10)` make sure that only 10 of those rows are sent from the database server to the web server, or will all 1000+ rows be sent (though only 10 would be sent to the client)?