I have a Linq Query, Which Returns alot of results From SQL Server, I want to make sure, I get the records from database ONCE and then simply loop through the records on demand within the page without hitting DB.
Here is a Simple Query:
Dim c1 = (From c2 In _db.CategoryRelationShip
Select c2)
Now Somewhere in Page I do:
For Each item In c1
Next
And Then Again:
For Each item In c1
Next
Does this mean in every For Loop, I am hitting database again and again? or my orignal Linq retieved all the records and i am simply looping through the array/results?
I heard about toList() method, so i am confused do i need it or not?... i mean what if I do:
Dim c1 = (From c2 In _db.CategoryRelationShip
Select c2).toList()