Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,051
- Reaction score
- 17,805
I have been stuck on this for a bit now. I have a Customer table and a Vehicle table. Some of the customers have 0 vehicles. Some of them have several.
I need to return all Customers that have 4 or more vehicles
Sounds simple, in LINQ I am struggling. This is the idea.
I need to return all Customers that have 4 or more vehicles
Sounds simple, in LINQ I am struggling. This is the idea.
C#:
public List<Customers> GetCustomers()
{
var result = (from customers in dbContext.customers
join vehicles in dbContext.vehicles
on customers.customerID equals vehicles.CustomerID
where customers.Count >= 4
select new Customers
{
Name = customers.Name,
CellNo = customers.CellNo,
}).ToList();
return result;
}