中的LINQ操作 [英] Linq IN Operator

查看:127
本文介绍了中的LINQ操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图寻找这一点,但无法找到适合我的情况的例子。

我有回头客此方法。如何使用的$字符串数组C $ CS来筛选呢?包含不为我工作。

 公共静态列表<客户> GetCustomers的(字符串[]客户codesArray)
{
    使用(busDataContext G =新busDataContext())
    {
        返回g.Customers.Where(
            X => x.customer code.Contains(客户codesArray))了ToList()。
    }
}


解决方案

请尝试以下code:

 返回g.Customers.Where(X =>客户codesArray.Contains(x.customer code))。了ToList();

I've tried searching for this but couldn't find examples that suited my situation.

I have this method for returning customers. How can I use the string array of codes to filter it? Contains doesn't work for me.

public static List<Customer> GetCustomers(string[] customerCodesArray)
{
    using (busDataContext g = new busDataContext())
    {
        return g.Customers.Where(
            x => x.customerCode.Contains(customerCodesArray)).ToList();
    }
}

解决方案

Try the following code:

return g.Customers.Where(x => customerCodesArray.Contains(x.customerCode)).ToList(); 

这篇关于中的LINQ操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆