我在ASP MVC
中创建了一个actionresult,它应该显示与我的Linq
查询匹配的记录。它正常工作,直到我说:like运算符给出零结果
records.State == '0' &&
这个查询(以T-SQL)返回SQL Management Studio中正确的结果,但不能使用LINQ:
public ActionResult Index(string q)
{
viewModel.Records = from records in db.records
where records.State == '0' &&
records.Title.Contains(q)
|| records.Title.Contains(q)
||records.Project.Contains(q)
|| records.Owner.Contains(q)
|| records.Number.Contains(q)
select events;
}
是什么State'的'类型? – Shyju
@Shyju这个类型是tinyint –
@CitizenDB那么你为什么要把它与'char'比较呢?试试'records.State == 0'。通过比较'0',你实际上将它与数字值48比较 – juharr