LINQ INNER JOIN WITH OR CONDITION.

Norman Reedus

Total Post:45

Points:315
Posted by  Norman Reedus
C#  LINQ  Mvc 
 659  View(s)
Ratings:
Rate this:
We want to Inner Join with OR condition in linq. How to Write this query please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: Linq Inner Join with OR condition.

    when we need to apply inner join with or condition. To write query for inner join with or condition we need to use || operator in where condition as shown below:

    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 prd in context.ProductStock

    from ord in context.ProductOrder

    where (prd.ProductName==ord.ProductName || ord.ManufacturedBy==prd.ManufacturedBy)

    select new

    {

    ord.OrderId,

    prd.ProductId,

    prd.ProductName,

    prd.ManufacturedBy,

    ord.OrderDate,

    ord.OrderQty

    }).ToList();

    return View();

    }

    }

    }

Answer

NEWSLETTER

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