[英]System.Linq.Dynamic: How to declare an array for .Contains?
I am trying to do a simple SQL where field in (2,3,4)
with Dynamic Linq. 我正在尝试使用Dynamic Linq where field in (2,3,4)
做一个简单的SQL。 kahanu's rehosted Microsoft Dynamic Linq Library has a .Contains()
that you can use in Linq like this: kahanu重新托管的Microsoft Dynamic Linq库具有一个.Contains()
,可在Linq中使用,如下所示:
var results = myTable.Where("@0.Contains(outerIt.abc)", new int[] { 2, 3, 4});
How would you remove the array parameter and specify the array in the string? 您将如何删除array参数并在字符串中指定数组? Something like this but actually works? 这样的东西,但实际上有效吗?
var results = myTable.Where("[2,3,4].Contains(outerIt.abc)");
I looked through his Microsoft documentation but it doesn't explain the .Contains()
All the documentation I've found on the Internet only refers to creating an array and passing it as a parameter like the first example above, but I found nothing on how to do the second example with just strings. 我浏览了他的Microsoft文档,但没有解释.Contains()
我在Internet上找到的所有文档都只涉及创建数组并将其作为参数传递,就像上面的第一个示例一样,但是我什么都没找到如何仅使用字符串执行第二个示例。
When using System.Linq.Dynamic.Core you can don something like: 使用System.Linq.Dynamic.Core时,您可以做以下事情:
var intList = new[] { 2, 3, 4 };
var results = myTable.Where("@0.Contains(outerIt.abc)", intList);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.