开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜