public int CalculateRating(string hotelID) { var RatingQuery = from a in db.tbl_Reviews where a.HotelID == hotelID group a by a.HotelID into g select new { TotalRating = g.Sum(a => a.Rating) }; int totalRating = Convert.ToInt16(RatingQuery.FirstOrDefault().TotalRating); int totalnoofRating = db.tbl_Reviews.Count(n => n.HotelID == hotelID); int newrating = (totalRating / totalnoofRating); return (newrating); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)