I'm finding it difficult to understand how I can create a LINQ query to do the following:
I have a table call lodge and I want to get back a single result which represents the call which has the longest duration.
The row looks like this:
[ID] [remote] [duration]
There are several rows for the same remittances Each can show a specific call period. I want to know that there is the longest duration in the remote part.
By using LINQ, I have found this far away:
var callStats = (from database to c. Calllog group C by selecting c in c.RemoteParty New {Remote Party = d.Key, TotalDuration = d.Sum (x = & gt; x.Duration)});
So now I have a grouped result for each remotepart with the total duration but I need a maximum single result [Distinct ramotteparty 2] [duration] [specificRemoteparten] [duration] How can I modify the query to get it?
Order the results and return the first one.
var callstats = (from database to C. Calllog group c by c.RemoteParty d Select new {RemoteParty = d.Key, TotalDuration = d.Sum (x => x Period) }); CallStats = callStats.OrderByDescending (a => an additional duration). FirstOrDefault ();
Comments
Post a Comment