有没有更好的方法来创建以下linq to sql查询?我想让所有公司名称以数字[0-9] ...
开头var suppliers = from s in context.Supplier where
SqlMethods.Like(s.CompanyName, "0%") ||
SqlMethods.Like(s.CompanyName, "1%") ||
SqlMethods.Like(s.CompanyName, "2%") ||
SqlMethods.Like(s.CompanyName, "3%") ||
SqlMethods.Like(s.CompanyName, "4%") ||
SqlMethods.Like(s.CompanyName, "5%") ||
SqlMethods.Like(s.CompanyName, "6%") ||
SqlMethods.Like(s.CompanyName, "7%") ||
SqlMethods.Like(s.CompanyName, "8%") ||
SqlMethods.Like(s.CompanyName, "9%")
select s;
非常感谢
答案 0 :(得分:4)
怎么样:
var suppliers = from s in context.Supplier where
SqlMethods.Like(s.CompanyName, "[0-9]%")
select s;