Home > DeveloperSection > Forums > LINQ Inner Join
Norman Reedus
Norman Reedus

Total Post:45

Points:315
Posted on    March-15-2016 10:51 PM

 LINQ C#  LINQ  Mvc 
Ratings:


 1 Reply(s)
 246  View(s)
Rate this:
We want to use Inner Join in linq .how to write inner join  query  please help me.


aditya kumar Patel

Total Post:250

Points:1782
Posted on    March-15-2016 10:58 PM

Join. This is a keyword in LINQ. As with other query languages (such as SQL) joining matches every element in two collections based on some condition.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

namespace ForumMVC.Controllers

{

public class HomeController : Controller

{

forumEntities context = new forumEntities();

public ActionResult Index()

{

var q = (from pd in context.ProductStock

join od in context.ProductOrder on pd.ProductId equals od.ProductId

orderby od.OrderId

select new

{

od.OrderId,

pd.ProductId,

pd.ProductName,

od.OrderQty

}).ToList();

return View();

}

}

}


Don't want to miss updates? Please click the below button!

Follow MindStick