SELECT * FROM Customer WHERE Name 'LIKE [a-f]%'
How Can I acheive this in Linq??
In other words in linq how can i select all Names between a and f??
Thanks,
SELECT * FROM Customer WHERE Name 'LIKE [a-f]%'
How Can I acheive this in Linq??
In other words in linq how can i select all Names between a and f??
Thanks,
You could use C# Regex class to match records:
var selectedCustomers = from customer in customers
where Regex.Match(customer.Name, "^[a-f].*$").Success
select customer;
There's a helper class called SqlMethods in the System.Data.Linq.SqlClient
namespace that provides a Like
method that emulates the SQL LIKE statement.
Your query would be:
var query = from c in Customers
where SqlMethods.Like(c.Name, "[a-f]%")
select c;