Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I do a "like" wildcard comparison in Entity Framework in .NET 4.0?

I'm using the Visual Studio 2010 RC for .NET 4.0 and I'm trying to figure out how to do a wildcard comparison with Entity Framework.

I'd like to have the following query for EF where I find all the names that start with 'J'

select * from Users where FirstName like 'J%'
like image 379
Paul Mendoza Avatar asked Jan 27 '26 21:01

Paul Mendoza


2 Answers

from user in Users where user.FirstName.StartsWith("J") select user;
like image 102
David Morton Avatar answered Jan 29 '26 10:01

David Morton


Use:

var query = Users.Where(user => user.FirstName.StartsWith("J"));
like image 40
Ahmad Mageed Avatar answered Jan 29 '26 09:01

Ahmad Mageed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!