Let's say I have 3 tables: carts, baskets and eggs where a basket can contain many eggs and where carts contain many baskets. Each basket has a foreign key that maps to a cart and each egg has a foreign key that maps to a basket.
I need to return a table that contains these 3 columns:
Cart Name | Count of Baskets in Cart | Count of Eggs in Cart.
Each table is an EF and I'm using linq with VB.
So far, I have 2 queries: one that returns the columns Cart Name and Count of Basket and another one that returns Cart Name and Count of Eggs. How can I combine these two result tables so that I get the results in one table?
Dim query1 = (From cart In myEntities.Carts
Where cart.UserID = TheUserID
Join baskets In myEntities.Baskets On baskets.CartID Equals cart.CartID
Select cart.CartName, cart.baskets.Count()).Distinct()
Dim query2 = (From cart In myEntities.Carts
Where cart.UserID = TheUserID
Join baskets In myEntities.Baskets On baskets.CartID Equals cart.CartID
Select cart.CartName, baskets.Eggs.Count()).Distinct()
Thanks for your help.