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,
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;
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With