I have a winform-application and using EF 4.2. I read that in EF 4.2 the linq to entity-queries are autocompiled.
When calling a query I do the following:
using (BVSEntities bvsContext = new BVSEntities(ConnectionString))
{
var person = (from sender in bvsContext.T_Absender
where sender.Absender_ID == id
select sender).First<T_Absender>();
return person;
}
Questions:
1) Is this query auto-compiled?
2) If it’s autocompiled. Is the compiled query reused because the bvsContext is disposed after the using?
3) If not, how can I reuse it but don’t get any concurrency-problems?
No because EF 4.2 doesn’t include autocompiled queries. It was supposed that EF 4.2 will include them but after that naming conventions for EF has changed. Autocompiled queries are part of .NET 4.5. EF 4.2 is just EF 4.1 with some fixes.
.NET 4.5 contains internal cache for autocompiled queries to reuse them.