views:

80

answers:

2

I have an ASP.net site that is essentially just a user interface for a class library I created. Each of the classes in this class library contain a static definition class with static references to compiled queries.

Like so:

class MyRecord
{
     /*Some Properties,Fields, and Methods*/

     internal static class Queries
     {
          public static Func<MyDataContext, MyRecord> ACompiledQuery = 
               CompiledQuery.Compile<MyDataContext, MyRecord>(
                    (MyDataContext db) => 
                         from mr in db.MyRecords
                         select mr);
     }
}

Given this structure and given that each web page references this library, I have a couple questions

Question 1: Every request to an IIS web server essentially starts a new thread, correct?

Question 2: If so, does this mean that for every request I end up recompiling these querries?

Question 3: Is there anyway to reduce the amount of times I recompile these querries?

+1  A: 

Static items are shared across threads within the same AppDomain, and so you will no re-compile the query for each request.

Joel Coehoorn
A: 

Question 1: Every request to an IIS Web server is handled by an existing thread from the application's threadpool

Question 2: Already answered by Joel

Question 3: It is Static so is only either created (or compiled) once when the application is started

Harry