In a website, if I have a class:
public class Provider
{
static readonly Func<Entities, IEnumerable<Tag>> AllTags =
CompiledQuery.Compile<Entities, IEnumerable<Tag>>
(
e => e.Tags
);
public IEnumerable<Tag> GetAll()
{
using (var db = new Entities())
{
return AllTags(db).ToList();
}
}
}
In a page I have:
protected void Page_Load(object sender, EventArgs ev)
{
(new Provider()).GetAll();
}
How many times the query will be compiled? Every time the page loads...? Once in the application...?
since it is a static member, once when class is loaded in app domain.
Seeing it is compiled. I would say once. Why would it need to be recompiled? Isn't that the point of compiled queries?
Given the compiled query is static, once per application instance/lifetime. Note: Lifetimes may overlap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With