How to use Linq to group, sum or retrieve total. My current code returns nothing
问题 I have this code which I'm trying to use in retrieving the fish pond with the highest use of feed in a month, so I need to group by Pool_Name , sum feed usage and then select the highest record after sorting. Here's an example code: var hfeed = db.feed_fish .Where(x => (DbFunctions.TruncateTime(x.Feed_Time) >= frm && DbFunctions.TruncateTime(x.Feed_Time) <= todat)) .GroupBy(x => x.Pond_Name) .Select(y => new feed_fish { Pond_Name = y.Key, Total_feed_weight = y.Sum(d => d.Total_feed_weight) })