简体   繁体   中英

Find item from the list

equipment has three items, and carspecification is a list item. In the carspecification , there is an equipmentId property.

How could I able to find equipment item(s) to find only equipment matches with equipmentId in carspecification .

 var equipment = _carService.GetCarEquipment(carId);
 var carSpecification = _carSpecificationService.GetId(specificationId);

I have tried the following, but it does not work.

 var eq = equipment.Select(x => x.Id.Equals(carSpecification.Select(y=> y.EquipmentId)));

您可以使用任何:

var result = equipment.Where(e => carSpecification.Any(s => s.specificationId == e.Id));
equipment.Where(e => carSpecification.Select(c => c.EquipmentId).Contains(e.Id))

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