MVC LINQ周平均值

时间:2016-08-12 12:49:33

标签: c# asp.net-mvc linq

 var query = from booking in context.BookingTables
             join transport in context.TransportAllotments on booking.TransportAllotmentID equals transport.TransportAllotmentID
             join passenger in context.Passengers on booking.BookingID equals passenger.BookingID
             join result in context.QuestionaireResults on passenger.PassengerID equals result.PassengerID
             join question in context.QuestionaireQuestions on result.QuestionaireQuestionID equals question.QuestionaireQuestionID
             where transport.DepartureDate >= startDate && transport.DepartureDate <= endDate && booking.BookingID == id
             orderby transport.DepartureDate ascending
             select new QuestionaireDetailsDTO()
             {
                 ID = booking.BookingID,
                 Date = transport.DepartureDate
             };

我收到了这段代码,给我回复了QuesionaireDetails,例如ID,日期,周数,结果(从1到10)和浮动平均值,它应该是每周数字的平均结果。

例如:有多个用户在同一周内有结果。我想做一个平均值,将它存储在数组和周++中。

这应该发生在web api中。任何建议都将不胜感激。

0 个答案:

没有答案