views:

475

answers:

4

I have a exchange rate table. I need to get current rate and previous rate and then compare results.

I can get first record using FirstOrDefault.

When i using ElementAtOrDefault,error show "The query operator 'ElementAtOrDefault' is not supported". How can i get second record?

+2  A: 

If you use

.Take(2)

you will get the first and second.

EDIT- If you need both the first and second, then the above will be more efficient than runing your query twice:

.Take(1)
.Skip(1).Take(1)
ck
Or Skip(1).Take(1) to get only 2nd.
Blorgbeard
+4  A: 

You can try this:

var query=data.Skip(1).Take(1);
Valentin Vasiliev
+1  A: 

Select top 2, then select second element.

Anton Gogolev
A: 

Use .Skip(1) method

Adinochestva