The range and individual values are created at runtime and stored in memory,
so it is the dynamic buildiing of this staement that are a bit tricky.

Signature
Harald SMS
> When building a query for the LinkToSql a need to build a where clause that
> has both individual values and range selections like this SQL Query:
[quoted text clipped - 3 lines]
>
> How can I write a LINQ statement that makes a efficient query like this?
Jon Skeet [C# MVP] - 18 Oct 2007 15:34 GMT
On Oct 18, 10:13 am, Harald SMS <Harald...@discussions.microsoft.com>
wrote:
> The range and individual values are created at runtime and stored in memory,
> so it is the dynamic buildiing of this staement that are a bit tricky.
If you build it up using extension methods directly instead of a query
expression, it's not too bad:
var query = dataContext.WhicheverTable; // The source part
if (restrictByFirstCriterion)
{
query = query.Where(item => item.Foo > wibble);
}
if (restrictBySecondCriterion)
{
query = query.Where(item => item.Bar < 0);
}
etc
Basically keep applying Where clauses (or others, such as joins) as
appropriate.
Jon