問題:
I have a procedure in SQL that I am trying to turn into Linq:我在 SQL 中有一個過程,我試圖將其轉換爲 Linq:
SELECT O.Id, O.Name as Organization
FROM Organizations O
JOIN OrganizationsHierarchy OH ON O.Id=OH.OrganizationsId
where OH.Hierarchy like '%/12/%'
The line I am most concerned with is:我最關心的一行是:
where OH.Hierarchy like '%/12/%'
I have a column that stores the hierarchy like /1/3/12/ for example so I just use %/12/% to search for it.例如,我有一列存儲像 /1/3/12/ 這樣的層次結構,所以我只使用 %/12/% 來搜索它。
My question is, what is the Linq or .NET equivalent to using the percent sign?我的問題是,Linq 或 .NET 相當於使用百分號是什麼?
解決方案:
參考一: https://stackoom.com/question/3VQU參考二: How to do SQL Like % in Linq?