4

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>()?

MrBliz
  • 5,830
  • 15
  • 57
  • 81

1 Answers1

10

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 )

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939