You can use the Join method directly, rather than using the query syntax:
public IQueryable<Customer> FindCustomers(Expression<Func<Customer, Address, bool>> predicate) { return DB.Customers.Join(DB.Addresses, c => c.ID, a => d.CustomerID, (c, a) => new { Address = a, Customer = c}) .Where(pair => predicate(pair.Address)) .Select(pair => pair.Customer) }
or you can pass both Customer and Address :
public IQueryable<Customer> FindCustomers(Expression<Func<Customer, Address, bool>> predicate) { return DB.Customers.Join(DB.Addresses, c => c.ID, a => d.CustomerID, (c, a) => new { Address = a, Customer = c}) .Where(pair => predicate(pair.Customer, pair.Address)) .Select(pair => pair.Customer) }
then you can create your array as:
IQueryable<Customer>[] queries = expressions.Select(expr => FindCustomers(expr)).ToArray();
source share