如何在 Linq 中執行 SQL Like %? - How to do SQL Like % in Linq?

問題:

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?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章