如何在实体框架中应用LIKE

时间:2017-09-03 13:25:59

标签: c# sql-server entity-framework asp.net-core

我试图根据输入字符串过滤掉结果,我需要使用SQL LIKE操作,而不是正常的比较。无法在线找到解决方案(可能没有使用正确的搜索词):

return _context.Cities.Where(t => t.Name == cityName);

我需要它WHERE t.name LIKE '%CityName%'。我如何在这里模拟它?

1 个答案:

答案 0 :(得分:0)

_context.Cities.Where(t => t.Name.Contains(cityName));

相关问题