Reputation: 3181
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 queries?
Question 3: Is there anyway to reduce the amount of times I recompile these queries?
Upvotes: 1
Views: 225
Reputation: 13909
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
Upvotes: 0
Reputation: 415705
Static items are shared across threads within the same AppDomain, and so you will no re-compile the query for each request.
Upvotes: 1