LINQ find max/min value with corresponding time fields?

Let maxTemp = c. Max(c=>c. Temp) let minTemp = c.

Min(c=>c. Temp) select new { LogDate = g. Key, MaxTemp = maxTemp, MinTemp = minTemp, MaxTime = g.

FirstOrDefault(c=>c. Temp = maxTemp). Time, MinTime = g.

FirstOrDefault(c => c. Temp = minTemp). Time, Rain = g.

Max(c => c. Rain_today), }.

Thanks for the responses guys. However I cannot get any of them to work. I don't think I made myself clear though.

I was after the corresponding LogTime (in the same row) of the Daily Max and Min temperatures, which are obtained through the Group by LogDate. – Corretto Jun 11 at 4:18.

Var q = from c in db. Apr11log group c by c. LogDate into g orderby g.

Key select new { LogDate = g. Key, MaxRow = g. OrderByDescending(c => c.

Temp). Select(c => new { c. LogDate, c.

Temp }).First(), MinRow = g. OrderBy(c => c. Temp).

Select(c => new { c. LogDate, c. Temp }).First(), Rain = g.

Max(c => c. Rain_today), }; or var q = from c in db. Apr11log group c by c.

LogDate into g orderby g. Key let maxRow = g. OrderByDescending(c => c.

Temp).First() let minRow = g. OrderBy(c => c. Temp).First() select new { LogDate = g.

Key, MaxTemp = maxRow. Temp, MaxTempDate = maxRow. LogDate, MinTemp = minRow.

Temp, MinTempDate = minRow. LogDate, Rain = g. Max(c => c.

Rain_today), }.

I'm a fan of the second option. Reads more logically – nathan gonzalez Jun 11 at 3:24 Thanks for this Alex, this works well. Just had to change LogDate to LogTime :-) – Corretto Jun 11 at 4:41.

MaxRow = g. OrderByDescending(c => c. Select(c => new { c.

MinRow = g. OrderBy(c => c. Select(c => new { c.

Max(c => c. Var q = from c in db. Group c by c.

Let maxRow = g. OrderByDescending(c => c. Let minRow = g.

OrderBy(c => c. LogDate = g. MaxTemp = maxRow.

MaxTempDate = maxRow. MinTemp = minRow. MinTempDate = minRow.

Max(c => c.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions