views:

28

answers:

1

Is it possible to compile queries which will be used with paging and sorting? For example does this make sense:

this.query = CompiledQuery.Compile<...>(
..
from row in dbx.Table select row
)

..

var select = this.query.OrderBy(..).Skip(..).Take(..);

Is this plausible? Or will it recompile every time Order, Skip, Take parameters change? Should I go back to regular queries instead of compiling them?

+1  A: 

In your example, the query would be recompiled every time.

However, if you put your paging inside the compiled query, then it will compile the paging part, as well.

Craig Stuntz
You mean like this: this.query = CompiledQuery.Compile<...>(..(from row in dbx.Table select row).OrderBy(param1).Skip(param2).Take(param3))
Yes, like that .
Craig Stuntz
Note that not all DBs can use params for `OrderBy`, though
Craig Stuntz