Sunday, June 3, 2018

Group By with Join in LINQ(SQL Expression)



var tempMostSellerCategory = from n in db.Temp_MostPopular
                                                 join m in db.Categories on n.CategoryID equals m.CategoryID
                                                 select new { n,m } into t1
                                                 group t1 by t1.n.CategoryID into g
                                                 select new
                                                 {
                                                     categoryid = g.FirstOrDefault().n.CategoryID,
                                                     title=g.FirstOrDefault().m.Title

                                                 };

No comments:

Post a Comment