LINQ to SQL - Inner Join

Language Integrated Query (LINQ, pronounced “link”) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages, released initially as a significant part of .NET Framework 3.5 in 2007.
In this post, I am going to show you how to generate inner join using LINQ to SQL. For this post, I am going to use Categories and Product table of northwind.

Let’s imagine that you want to fetch CategoryNameandProductName from the above table using LINQ.
var query=from p in Products
          join c in Categories
          on p.CategoryID equals c.CategoryID
          select new
          {
          CategoryName=c.CategoryName,
          ProductName=p.ProductName
          };
Reactions

Post a Comment

0 Comments

Close Menu