I have a scenario in following nested
--Orders (List)
----Products (List)
------Manufacturers (List)
FIELDS
-Name
-Address
-City
In this scenario, I would need to execute query which will filter on City of Manufacturers and returns Orders, Products & only matching city manufacturers
I tried to put following query, however I am getting all list of Products even though city doesn't match to Manufacturers.
var filteredOrders = from o in Orders
from t in o.Products
where t.Manufacturers.Any(v => v.City == "Hartford")
select o;
Or even if I change from select o to 'select t.Manufacturers' I am getting all list of Manufacturers irrespective of city filter.
Luckily I got W3school SQL sample which matches to my scenario. https://www.w3schools.com/sql/trysql.asp?filename=trysql_op_or
SQL Query:
SELECT o.OrderId, p.ProductName, s.*
FROM [Orders] o
JOIN OrderDetails od ON o.OrderId = od.OrderId AND o.orderId = 10248
JOIN Products p ON od.ProductId = p.ProductId
JOIN Suppliers s ON p.SupplierId = s.SupplierId and s.City ='Singapore'
pofp.Products?Any()return true or false, so if any of the city is "Hartford", it return true, means you filter nothing. Try simplest exact where clause:where t.Manufacturers.City == "Hartford"Manufacturesis a collection so it doesn't have aCityproperty to filter on.