Is there a C# IN operator?

后端 未结 14 1878
说谎
说谎 2020-12-08 03:51

In SQL, you can use the following syntax:

SELECT *
FROM MY_TABLE
WHERE VALUE_1 IN (1, 2, 3)

Is there an equivalent in C#? The IDE seems to

14条回答
  •  盖世英雄少女心
    2020-12-08 04:15

    I do something like this:

    var shippingAddress = checkoutContext.Addresses.Where(a => (new HashSet { AddressType.SHIPPING_ONLY, AddressType.BILLING_AND_SHIPPING }).Contains(a.AddressType) && a.Id == long.Parse(orderDto.ShippingAddressId)).FirstOrDefault();
    

提交回复
热议问题