How do I filter a query interval of two string using LINQ or Lambda Expression.
example:
SELECT * FROM dbo.Country WHERE Name BETWEEN "Argentina" AND "Jamaica";
How do I filter a query interval of two string using LINQ or Lambda Expression.
example:
SELECT * FROM dbo.Country WHERE Name BETWEEN "Argentina" AND "Jamaica";
perpetrators >= and <= are not for strings. they will throw compile time error to you. you can use CompareTo for this as shown below
x.Name.CompareTo(Start) >= 0 && x.Name.CompareTo(End) <= 0
Have you tried:
yourDataContext.Country.Where(c => c.Name >= "Argentina" && c.Name <= "Jamaica");
c.Name.CompareTo("Argentina") >= 0 && c.Name.CompareTo("Jamaica") <= 0
, but I'm not sure whether this translates through the entity framework.
var query = yourDataContext.Country..Where(Name => Name.IsBetween(Argentina, Jamaica));