gpt4 book ai didi

c# - linq to sql - 我如何重写以下内容

转载 作者:太空宇宙 更新时间:2023-11-03 22:25:50 24 4
gpt4 key购买 nike

是否有更好的方法来创建以下 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;

非常感谢

最佳答案

关于:

var suppliers = from s in context.Supplier where 
SqlMethods.Like(s.CompanyName, "[0-9]%")
select s;

关于c# - linq to sql - 我如何重写以下内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1455310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com