1

I am having a orchestration which will call a static method in a static class. I just discovered that if you need to run a Linq query a lot of times it is a good idea to make it into a compiled query. And my orchestration will be spawned a lot of times.

But im not sure I will win anything by making it into a compiled query.

Will each orchestration has to compile the query or will it be shared?

user640691
  • 11
  • 1

1 Answers1

0

Each orchestration will execute on it's own thread so each orchestration will have it's own copy of the method's local variables including the linq query. So the query will be compiled every time the method is called.

Not sure how you can get around this, because the lifetime of the static class is determined by the lifetime of the orchestration. You could implement a singleton orchestration which could then call a non-static method. That way you could have the first call compile the query and all subsequent calls use the same query.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
  • 1
    I don't think you are correct in your description. The lifetime of a static class is the lifetime of the application domain, which is not the lifetime of the orchestration, a static value will be reused between instances if running on the same host before the app domain got recycled, some semi-related thoughts here - http://blog.sabratech.co.uk/2007/08/thoughts-about-static-members-and-local.html – Yossi Dahan Mar 18 '11 at 20:31