george willy
george willy

Reputation: 1713

orderby Clause in linq

I have this linq syntax that I would like to order by the results based on LocalDateTime field

from d in Devices

where d.Name=="switch01"


select new {d.deviceId, Performance=d.Performance.system.io}

LocalDatetime is a property of io. I can get the results but they are not ordered by date and time.

LocalDateTime is type DateTime here is the output:

LocalDateTime   Value
3/9/2012 1:05   5000.7
3/9/2012 1:15   4775.6
3/9/2012 1:35   3743.3
3/9/2012 9:05   656.3
3/9/2012 7:45   670.4
3/9/2012 10:15  621.7
3/9/2012 7:15   665.4
3/9/2012 7:10   603.9

Upvotes: 1

Views: 171

Answers (1)

Saeed Amiri
Saeed Amiri

Reputation: 22565

from d in Devices

where d.Name=="switch01"

orderby d.Performance.system.io.LocalDatetime 

select new {d.deviceId, Performance=d.Performance.system.io}

Upvotes: 3

Related Questions