Completely Free .NET word API

Resources » Code Snippets » Visual Studio

Linq join on multiple columns

Updated: Category: Visual Studio
Author: Member Level: GoldPoints: 10

How to perform join in Linq Concepts with multiple columns?

Simple join using Linq to SQL Have one columns id in both table

ar qry = from tmep in table1
join temp1 in table2
on {temp.ID} equals {temp1.ID}

have two columns id and country in both table

var qry = from tmep in table1
join temp1 in table2
on new {temp.ID,temp.Country} equals new {temp1.ID,temp2.Country}

how to join in multiple table ?

Select distinct MMC.ClmNoKey, MMC.CaseNoKey, SP.ApppointDt, SP.RefNo, MMC.ClmTypeCd, CT.ClmTypeGroupCd, CT.Dsc, SP.SpCd, MMC.CoUserCd, M.VehNo
from CmastOwnSP SP

join MCMastCase MMC on SP.ClmNoKey = MMC.ClmNoKey
join uClmType CT on MMC.ClmTypeCd = CT.ClmCaseTypeCdKey
join MCMast as M on M.ClmNoKey = SP.ClmNoKey
join CMast as CM on SP.ClmNokey = CM.ClmNokey

where spcd = 'MCSTKL' and Sp.AppointDt is not Null and Sp.AckDt is Null
and CT.ClmTypeGroupCd = Sp.ClmTypeCd and MMC.ClmCaseStatusCd <> ‘C’
and SP.DelInd = 0

related LINQ Query

var Query = from objSP in
(from SP in objClaimStatusDC.CMastOwnSPs
join MMC in objClaimStatusDC.MCMastCases on SP.ClmNoKey equals MMC.ClmNoKey
join CT in objClaimStatusDC.uClmTypes on MMC.ClmTypeCd equals CT.ClmCaseTypeCdKey
join M in objClaimStatusDC.MCMasts on SP.ClmNoKey equals M.ClmNoKey
join CM in objClaimStatusDC.CMasts on SP.ClmNoKey equals CM.ClmNoKey
where SP.SPCd == 'mcstkl' && SP.AppointDt != null && SP.AckDt == null && SP.DelInd == false && MMC.ClmCaseStatusCd != "C"

select new

select new
ClmNoKey = objSP.ClmNoKey ?? "",
AppointDt = objSP.AppointDt,
RefNo = objSP.RefNo,
CoUserCd = objSP.COUserCd,
Dsc = objSP.Dsc,
Ins = objSP.Ins,
VehNo = objSP.VehNo,
CaseNoKey = objSP.CaseNoKey,
ClmTypeCd = objSP.ClmTypeCd,
GroupCD = objSP.ClmTypeGroupCd,
SPCD = objSP.SPCd,


Did you like this resource? Share it with your friends and show your love!

Responses to "Linq join on multiple columns"

No responses found. Be the first to respond...


Post Comment:

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)

    Type the numbers and letters shown on the left.

    Submit Article     Return to Article Index
    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India