如何添加 where 以获取并非所有值?
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();
用户必须从comboBox中选择国家/地区,之后我想在这个国家/地区只选择一种住宿并在下一个comboBox中获取
答案 0 :(得分:1)
试试这个:
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();