Home / Data / Linq
from c in db.Category from p in db.Product where p.CategoryID == c.CategoryID select new { c.CategoryName, p.ProductName };
SQL:
SELECT [c].[CategoryName], [t1].[ProductName] FROM [Categories] [c], [Products] [t1] WHERE [t1].[CategoryID] = [c].[CategoryID]
from p in db.Product join c in db.Category on p.CategoryID equals c.CategoryID select new { c.CategoryName, p.ProductName };
SELECT [t1].[CategoryName], [p].[ProductName] FROM [Products] [p] INNER JOIN [Categories] [t1] ON [p].[CategoryID] = [t1].[CategoryID]
In the end here we have such clumsy Left Join.
from p in db.Product join c in db.Category on p.CategoryID equals c.CategoryID into g from c in g.DefaultIfEmpty() select new { c.CategoryName, p.ProductName };
SELECT [t1].[CategoryName], [p].[ProductName] FROM [Products] [p] LEFT JOIN [Categories] [t1] ON [p].[CategoryID] = [t1].[CategoryID]
There was an error while loading. Please reload this page.