linq里LIKE的几种用法
方法1:Using String.StartsWith or String.Endswith
- var q = from c in db.Customers
- where SqlMethods.Like(c.CustomerID, "C%")
- select c;
方法2.Using SqlMethods.Like method
- C# code
-
var query = from c in ctx.Customers where SqlMethods.Like(c.City, "L_n%") select c;
方法3:
var q =from c in db.Customers where c.CustomerID.IndexOf("C")>-1select c;
方法4:当然是用CONTAINS了,不过这个只能实现 LIKE '%keyword%'这种
方法5:等你来完成!哈哈
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · 轻量级ORM框架(六):处理表达式树
- · 轻量级ORM框架(二):LinqToDB查询
- · LINQ to SQLite完美解决方案
- · LINQ to SQL公共基类 demo
- · C#函数式程序编程2
- · linq查询效率测试
- · Entity Framework入门到精通(一)-概念及架构
- · LINQ无主键无法更新表
- · LINQ查询返回DataTable类型
- · The instance of entity type ‘Customer’ cannot be tracked because another instance with the same key value for {‘Id’} is already being tracked.
- · .NET8实时更新nginx ip地址归属地
- · 解决.NET Blazor子组件不刷新问题