Given the following Structure
public class WorkOrderItem
{
[Key]
public long WorkOrderItemId { get; set; }
public virtual ICollection<Job> Jobs { get; set; }
}
public class Job
{
[Key]
public long JobId { get; set; }
public long? WorkOrderItemId { get; set; }
public virtual Item Item { get; set; }
public virtual Element ResultElement { get; set; }
}
How would i get a list of Items where the item had a job that the ResultElementid was in a List<long>()
?
You can use Any
+ Contains
:
var query = workOrderItems
.Where(item => item.Jobs.Any(j => longList.Contains(j.ResultElement.Id)));
( presuming that the class Element
has an Id
property since you've stated ResultElementid )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With