Otis wrote:
THere's no between equivalent, as the Linq syntax doesn't offer that. So instead use two compares and an '&&' / And statement.
I tried that but the resultant SQL ends up being something like:
SELECT ...
WHERE ((Field1 > @Param1) AND (Field1 < @Param2))
I tried every combination of >, <, >=, <=. I wouldn't expect a translation to BETWEEN, however BETWEEN is useful because the upper and lower bounds don't have to be in sequential order.
It would be nice if LLBLGen would implement an extension method like:
public static bool Between<T>(this T value, T a, T b) where T : IComparable<T> {
if (a.CompareTo(b) <= 0)
return value.CompareTo(a) >= 0 && value.CompareTo(b) <= 0;
else
return value.CompareTo(b) >= 0 && value.CompareTo(a) <= 0;
}
but of course using real types. And then when parsing the LINQ expressions, map the Between function call to the database representation.
Then you could do something like:
**from **o **in **meta.Order
**where **o.DateOrdered.Between(start, end)
**select **o;
I'm not sure if it would work, just an idea.