Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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();
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
136 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try the following code:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...