【发布时间】:2019-08-22 14:58:58
【问题描述】:
这是我的代码:
(from customer in db.tblCustomers
join product in db.tblProducts on customer.product_id equals product.id into str
from prod in str.DefaultIfEmpty()
where customer.code.Substring(SqlFunctions.PatIndex("%[^0]%", customer.code).Value - 1) == customerCode
select prod.name).SingleOrDefault();
如您所见,我使用 PatIndex 左修剪字符串,但我也想右修剪零。我该怎么做?
例如,如果 customerCode 是“123”,并且在 db 中,如果我有一个值为“001230000”的客户代码,则匹配。
【问题讨论】:
-
反转字符串,然后是相同的代码。
标签: c# entity-framework linq tsql