简体   繁体   中英

List get values by clause where

How can I add clause where for get not all values ?

        var response = proxy.GetInformation(
            new TravelAgencyService.Messages.TravelAgencyRequest()
            {
                Accommodation = comboBox1.SelectedItem.ToString()
            });
        List<string> kindOfAccommodation = response.Offers
        .Select(o => o.RodzajZakwaterowania )
        .Distinct()
        //.Where()??
        .OrderBy(c => c)
        .ToList();

User must select country from comboBox and after that I want to choose only kind of accommodation in this country and fetch in next comboBox

Try this:

 var response = proxy.GetInformation(
        new TravelAgencyService.Messages.TravelAgencyRequest()
        {
            Accommodation = comboBox1.SelectedItem.ToString()
        });
    List<string> kindOfAccommodation = response.Offers
    .Where(offer => offer.AttributeOfOffer == valueToFilter)
    .Select(o => o.RodzajZakwaterowania )        
    .Distinct()       
    .OrderBy(c => c)
        .ToList();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM