问题描述
我有下面的SQL查询,不包括从字母x
开始的行select * from table where name like 'x%'
如何使用linq?
编写它我尝试使用
var query = (from a in _tableARepository.AsQueryable() join b in _tableBRepository.AsQueryable() on a.Id equals b.Id where a.name.contains("x") select new { a, b});
,但这包括" x"
的所有内容推荐答案
如果a.name是字符串,只需使用where a.name.StartsWith("x").
问题描述
I have sql query like below which excludes rows starting from letter x
select * from table where name like 'x%'
How do i write it same using Linq?
I tried using
var query = (from a in _tableARepository.AsQueryable() join b in _tableBRepository.AsQueryable() on a.Id equals b.Id where a.name.contains("x") select new { a, b});
But this includes everything with "x"
推荐答案
If a.name is a string, just use where a.name.StartsWith("x").