0
我想在我的數據庫中找到最好的五家餐廳。數據庫的結構複雜了我的linq查詢。查詢找到最好的五家餐廳
這就是我的工作,我有一個包含一個外鍵到我的餐廳一表「的意見」和我有1個5
表例子之間的投票三種選擇:
- idRestaurant
- ratingOne
- ratingTwo
- ratingThree
因此,我要分類的餐廳,一個平均的平均的三個音符的
舉例來說,如果我有表中的一些記錄
idRestaurant 1 - RatingOne 2 - RatingTwo 2 - RatingThree - 2
idRestaurant 1 - RatingOne : 4 - RatingTwo : 4 - RatingThree - 4
idRestaurant 2 - RatingOne : 3 - RatingTwo : 3 - RatingThree - 3
idRestaurant 2 - RatingOne : 4 - RatingTwo : 4 - RatingThree - 4
idRestaurant : 3 - RatingOne 1 - RatingTwo 1 - RatingThree - 1
idRestaurant : 3 - RatingOne 1 - RatingTwo 1 - RatingThree - 1
idRestaurant : 4 - RatingOne 1 - RatingTwo 1 - RatingThree - 1
idRestaurant : 4 - RatingOne 1 - RatingTwo 1 - RatingThree - 1
idRestaurant : 4 - RatingOne 1 - RatingTwo 1 - RatingThree - 1
idRestaurant : 4 - RatingOne 5 - RatingTwo 5 - RatingThree - 5
我想我的LINQ的結果給我idRestaurants列表中總體得分順序不重複的餐廳 例如: {2,1,4,3}
我有以下查詢
var restosss = (from w in db.restos_cote
group w by w.idRestoSuccursale into g
select new
{
idRestoSuccursale = g.Key, Restos = g
});
但它也需要按平均分數排序。
分發布提問之前請出示努力。 Stack Overflow上很少有人想爲你做你的工作。你嘗試過什麼嗎?什麼是工作,什麼不工作? –
你好,我aleary有一個查詢組由resto,但我想奧伯由平均三個評級的平均值... var restosss =(從w db.restos_cote組w通過w.idRestoSuccursale到g選擇新{idRestoSuccursale = g.Key,Restos = g}); – user2913658