我在代码中使用了FromSql,当我尝试进行单元测试时,FromSql出现了问题。
var res = _context.People.FromSql(query).ToList().Where(
p => (p.FirstName + " " + p.LastName ?? "").ToLower().StartsWith(search.ToLower())
|| (p.FirstName.ToLower().StartsWith((search ?? p.FirstName).ToLower()))
|| p.LastName.ToLower().StartsWith((search ?? p.LastName).ToLower())
|| pharrays.Contains(p.PersonId) || emarrays.Contains(p.PersonId)
||p.PersonId.ToString().Contains(search));