相关疑难解决方法(0)

如何使用LINQ Contains(string [])而不是Contains(string)

我有一个大问题.

我有一个linq查询,它只是看起来像这样:

from xx in table
where xx.uid.ToString().Contains(string[])
select xx
Run Code Online (Sandbox Code Playgroud)

string[]数组的值将是(1,45,20,10等...)

为默认.Contains.Contains(string).

我需要它来代替: .Contains(string[])...

编辑:一位用户建议为其编写扩展类string[].我想知道如何,但任何人都愿意指出我正确的方向?

编辑: uid也是一个数字.这就是它被转换为字符串的原因.

帮助任何人?

c# linq string contains

94
推荐指数
5
解决办法
38万
查看次数

LINQ中的动态WHERE子句

将动态WHERE子句组装到LINQ语句的最佳方法是什么?

我在表单上有几十个复选框,并将它们传递回:Dictionary <string,List <string >>(Dictionary <fieldName,List <values >>)到我的LINQ查询.

public IOrderedQueryable<ProductDetail> GetProductList(string productGroupName, string productTypeName, Dictionary<string,List<string>> filterDictionary)
{
    var q = from c in db.ProductDetail
            where c.ProductGroupName == productGroupName && c.ProductTypeName == productTypeName
            // insert dynamic filter here
            orderby c.ProductTypeName
            select c;
    return q;
}
Run Code Online (Sandbox Code Playgroud)

c# linq dynamic where-clause

54
推荐指数
6
解决办法
11万
查看次数

标签 统计

c# ×2

linq ×2

contains ×1

dynamic ×1

string ×1

where-clause ×1