Let's say I write this little linqpad snippet and run it, I get what I expect
But when I hit F5 again, the list will have two items in it:
I was not expecting it to do this and can't figure how why it would.
The list will be growing everytime I run it unless I do something to the code, even add a comment. Then it will reset to one entry.
Is this by design? If so why? I'm on 5.08.01
It is by design. It does not reset the Application Domain unless you do one of the following:
1) Use Ctrl+Shift+F5 to reset it on demand
or
2) Go into Edit/Preferences/Advanced and set "Always use Fresh Process per execution" to True. This will reset every time you run a script
or
3) Put the following code into your query (this tells LINQPad to use a fresh domain next time you run):
Util.NewProcess = true;
As for why, there are probably multiple benefits but I'd say performance is the main one. You could put the results of an expensive query in a static variable and only run it the first time.