As shown in the above image, when I press on the ResultsView, it opens a new list which contains [0]
and [1]
. However, in my code, when I write sessionQueryable[0]
it says syntax error.
How can I access what's in the ResultsView?
The debugger is showing you the internal structure behind the IQueryable
interface, but you should not program against that, though, since there is no guarantee that you'll get the same structure each time.
IQueryable
lists cannot be accessed by index using []
. You'd need to turn it into an IList
to access it by index:
var list = user.Sessions.ToList();
Or query the sessions by some other method using the IQueryable
interface, for example Skip()
and Take()
:
var first = sessionsQueryable.Take(1); // First item
var second = sessionsQueryable.Skip(1).Take(1); // Second item
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With