将SQL查询转换为LINQ表达式-整数的LIKE运算符

|| 有人可以将以下简单的SQL语句转换为LINQ吗? StudentID的类型为int。 选择*从StudentId像\'%1001%\'的Student中; 谢谢!     
已邀请:
        
 ctx.Student.Where(x => x.StudentId.Contains(\"1001\"))
您具有字符串类型的ID感到很奇怪。 使用int代替。 哦,对不起,我现在知道,您写道id是整数。在这种情况下,您不能在SQL中使用like。 这没有道理。您必须先将int转换为字符串。
ctx.Student.Where(x => x.StudentId.ToString().Contains(\"1001\"))
    
        尝试这个:
db.Students.Where(s => s.StudentID.ToString().Contains(\"1001\"))
    
        使用包含运算符:
from s in Student
where s.studentId.ToString().Contains(\"1001\")
select s;
    

要回复问题请先登录注册