From the course: LINQPad Essential Training

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Cache data between query runs

Cache data between query runs - LINQ Tutorial

From the course: LINQPad Essential Training

Cache data between query runs

- [Instructor] Running queries against real sources could suffer from latency issues and other delays. For example, when we have a query that hits the network at a busy time, it could take 15 seconds to get the data back. We can use a LINQPad cache to speed up later query runs. I'm in Visual Studio and I've added a new method to the Visual Studio project that simulates a slow network, it's called Get Color Slow. And you can see it's just got two lines of code, it's putting a thread to sleep for 3000 milliseconds, and then it's returning all the colors in the original list. Over in LINQPad, I call Get Color Slow. And then I get the first five items and dump those to the screen. It took 3.111 seconds run that now if I run that query again, it takes 3.011 seconds. So it still has that latency issue. So what I can do is take this code here, Copy that, put it here, and I'll comment out this line. So what I'm doing…

Contents