Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
here i have two table, First for ProductDetails And Second for ProductLikes

Here I want to Get all Product List and Each rows will has like Count as column

how can i do using lambda expression
Posted

1 solution

SQL
Products.Join( ProductLikes, s => s.ProductID, d => d.ProductID, (s, d) => new { ProductID = s.ProductID, ImageUrl = s.ImageUrl,  StoreID = s.UserID, SoldCount = s.SoldCount })
.GroupBy(g => new { ProductID = g.ProductID, ImageUrl = g.ImageUrl  })
.Select(d => new { ProductID = d.Key.ProductID,  ImageUrl = d.Key.ImageUrl, TotalCount = d.Count( ) }) .ToList().Distinct()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900