ADO.NET Entity Framework Compiled Queries with ObjectSet Only
I cannot find an example of using a compiled query with the objectset intead of the ObjectContext inst开发者_JAVA百科ance... so is it possible to create a compiled query with only the ObjectSet? This will fit in better with my architecture.
Thanks.
Definition of the most simple Compile
version looks like:
public static Func<TContext, TResult> Compile<TContext, TResult>(Expression<Func<TContext, TResult>> query)
where TContext : ObjectContext
{
return new Func<TContext, TResult>(new CompiledQuery(query).Invoke<TContext, TResult>);
}
Invoking compiled query requires ObjectContext
, there is no version accepting ObjectSet
.
ObjectSet has a Context property. You would have to use that. One of the args to Compile( , )
must be a Context from what I can tell (as confirmed by @Ladislav.
精彩评论