views:

151

answers:

1

Is it at all possible to use something like a switch statement in a compiled query for linq to entities/sql? For example when returning sorted records from the database, I would like to use a switch-like statement within one compiled query to sort on different properties, instead of having to write 2 compiled queries (ascending & descending) for every property you might want to sort on, which can be up to 10 compiled queries for even a simple sortable grid.

In T-SQL this would be easy with a case statement, as I would imagine a construct like this is supported in most databases, so why would it not be supported in linq/entity framework.

Any solution for this?