LINQ INNER JOIN

Norman Reedus

Total Post:45

Points:315
Posted by  Norman Reedus
C#  LINQ  Mvc 
 574  View(s)
Ratings:
Rate this:
We want to use Inner Join in linq .how to write inner join  query  please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: LINQ Inner Join

    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();

    }

    }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!