In condition using LINQ

后端 未结 2 827
囚心锁ツ
囚心锁ツ 2021-01-22 07:07

OK, another LINQ question. How do I do an \"IN\" condition using LINQ. I have an IEnumerable list of myObject and want to do something like myObject.Description in(\'Help\',

2条回答
  •  一整个雨季
    2021-01-22 08:04

    IN in sql is equivalent is Contains in LINQ

    string[] countries = new string[] { "UK", "USA", "Australia" };
    var customers =
        from c in context.Customers
        where countries.Contains(c.Country)
        select c;
    

提交回复
热议问题