Linq: Need to make Selft join using multiple keys one is primary key and another with max of updated on date
Rate this content:                         
Dear Reader,

I have take the Theme Database as the sample

 

var ThemeDetailsLastUpdated = from r in dc.ThemeDetails

group r by r.ThemeID into rg

select new { ThemeID = rg.Key, DatedOn = rg.Max(p => p.DatedOn) };

 

 

the above code will get the max of last updated, with that we are going to self join

 

var ThemeDetailSelfJoin = from td in dc.ThemeDetails

join tdu in ThemeDetailsLastUpdated on

new { td.ThemeID, td.DatedOn } equals new { tdu.ThemeID, tdu.DatedOn }

select new { td.ThemeID };

   © 2009 Development Next. All Rights Reserved. | Terms of Use | Trademarks