如何使用“包含"或“喜欢"在动态 linq 查询中? [英] How to use "contains" or "like" in a dynamic linq query?
问题描述
CSharpSamples.zip 中 Dynamic Linq 附带的帮助文件没有显示任何使用 contains 或 like 的示例.
The help file that came with Dynamic Linq in the CSharpSamples.zip does not show any examples of using contains or like.
是否有任何简单的解决方法来执行此操作?即(col like @col)不起作用的地方.
Are there any simple workarounds for doing this? i.e where (col like @col) doesn't work.
推荐答案
答案在这里!动态 Linq 确实支持 .运算符,
Here is the answer! The Dynamic Linq does support the . operator,
根据文档:
"实例字段或实例属性使用权.任何公共领域或财产可以访问."
"Instance field or instance property access. Any public field or property can be accessed."
因此,可以使用这种语法
Thus, it is possible to use this syntax
.Where("MyColumn.Contains(@0)", myArray)
谢谢大家的建议!感谢我找到了解决方案.
Thanks for all the suggestions! And thanks to me for finding the solution.
这篇关于如何使用“包含"或“喜欢"在动态 linq 查询中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!