score:0

unfortunately, linq does not have a between operator or equivalent. the best (and possibly) only way to achieve this is in sql.

if you are looking to write complex or optimized queries, it is better to use sql rather than linq. the main advantages for this are:

  • code can be fully tested in management studio, without having to translate and debug in a second language
  • for legacy purposes, it is generally better to use sql for database access code, as this is more widely known amongst database experts. linq is the curse of dbas who have to manage/support code written by others.

i agree with gerge mauer's suggestion to use a stored procedure or ado.

this might still leave you with the problem of parameter sniffing, in which case you may have to use query hints such as optimize for / recompile, or local variables to get around this, as demonstrated in this article:

http://blogs.msdn.com/b/turgays/archive/2013/09/10/parameter-sniffing-problem-and-workarounds.aspx


Related Query

More Query from same tag