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

一个人想着一个人 提交于 2019-12-12 16:26:45

问题


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

回答1:


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



回答2:


Use:

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



回答3:


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



来源:https://stackoverflow.com/questions/2376191/how-do-i-do-a-like-wildcard-comparison-in-entity-framework-in-net-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!