Paul Mendoza
Paul Mendoza

Reputation: 5787

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%'

Upvotes: 3

Views: 4648

Answers (3)

David Morton
David Morton

Reputation: 16505

from user in Users where user.FirstName.StartsWith("J") select user;

Upvotes: 9

csjohnst
csjohnst

Reputation: 1678

I would refer you to this question, I assume it hasn't changed in .net 4.0

Upvotes: 0

Ahmad Mageed
Ahmad Mageed

Reputation: 96507

Use:

var query = Users.Where(user => user.FirstName.StartsWith("J"));

Upvotes: 3

Related Questions