怎么办SQL类似%Linq中?

编程入门 行业动态 更新时间:2024-10-27 10:24:21
本文介绍了怎么办SQL类似%Linq中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在SQL一个过程,我想变成的Linq:

SELECT O.Id,O.Name作为组织 从组织Ø JOIN OrganizationsHierarchy OH ON O.Id = OH.OrganizationsId 其中,OH.Hierarchy像'%/ 12 /%

我最关心的是该生产线是:

其中OH.Hierarchy像'%/ 12 /%

我有一个存储层级状/ 1/3/12 /譬如,所以我只是用%/ 12 /%至搜索。列

我的问题是,什么是LINQ的或.NET等同于使用百分号?

解决方案

。凡(OH => oh.Hierarchy.Contains(/ 12 /))

您也可以使用 .StartsWith()或 .EndsWith()。

I have a procedure in SQL that I am trying to turn into 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.

My question is, what is the Linq or .NET equivalent to using the percent sign?

解决方案

.Where(oh => oh.Hierarchy.Contains("/12/"))

You can also use .StartsWith() or .EndsWith().

更多推荐

怎么办SQL类似%Linq中?

本文发布于:2023-07-09 14:55:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1087131.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类似   SQL   Linq

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!