Linq to Devart 实体框架中的编译查询

发布于 2024-12-25 14:24:15 字数 951 浏览 5 评论 0原文

对于编译查询,在 LINQ to Object Entity FrameworkWork 中,基本上它允许查询一次编译,然后可以重复使用,而无需另一次编译。

例如:

using System.Data.Objects;
public static Func<entity, string, IQueryable<Entity>>
    TestQuery = CompiledQuery.Compile((entity db, string param) =>
        from e in ctx.Entities where e.Field == param select e);

我的问题是 LINQ to Devart Entity FrameWork ,无法传递实体。因为它只允许数据上下文作为有效参数。

请建议我如何将 linq 转换为用于编译查询的 devart 实体框架(edml)。

注意:它在“Devart LinqConnect Model(lqml)”中工作正常 例如:

 public static Func<MyContext.dataContext , long,
             IQueryable<EMyContext.dataContext.tableName>>
           shopByCountry = CompiledQuery.Compile((MyContext.dataContext db,     long idCountry) =>
             from a in db.Countries where a.idCountry == idCountryselect a);

但不在“Devart Entity Model”中,因为 edml 是“ObjectContext”,lqml 是“DataContext”

提前致谢,

For Compiled Queries, In LINQ to Object Entity FrameWork basically it allows the queries to compile at one time and then it can be re-used without compiling another time.

For Example:

using System.Data.Objects;
public static Func<entity, string, IQueryable<Entity>>
    TestQuery = CompiledQuery.Compile((entity db, string param) =>
        from e in ctx.Entities where e.Field == param select e);

My question is for LINQ to Devart Entity FrameWork , unable to pass the entity . cos it allows only datacontext as a valid parameter.

Please suggest me how to convert the linq to devart entity framework(edml) for Compiled Queries.

NOTE: it working fine in "Devart LinqConnect Model(lqml)"
For example :

 public static Func<MyContext.dataContext , long,
             IQueryable<EMyContext.dataContext.tableName>>
           shopByCountry = CompiledQuery.Compile((MyContext.dataContext db,     long idCountry) =>
             from a in db.Countries where a.idCountry == idCountryselect a);

but not in "Devart Entity Model" since edml is "ObjectContext" , lqml is "DataContext"

Thanks in Advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

佞臣 2025-01-01 14:24:15

CompiledQuery ( http://msdn.microsoft.com/en-us/library/bb896297 .aspx )在实体框架中仅支持 ObjectContext。对 DbContext (EF v4.1/EF v4.2) 没有此类支持: http://blogs.msdn.com/b/adonet/archive/2011/03/02/ef-4-1-is-coming-dbcontext-api-amp-code-first-rtw。 .aspx .您可能正在使用 DbContext。

对于 Entity Framework June 2011 CTP,可以避免显式编译,因为自动编译的 LINQ 查询是在 EF June 2011 CTP 中实现的:http://blogs.msdn.com/b/efdesign/archive/2011/06/30/auto-compiled-linq-queries-entity-framework-june-2011-ctp.aspx .

CompiledQuery ( http://msdn.microsoft.com/en-us/library/bb896297.aspx ) in Entity Framework is supported only for ObjectContext. There is no such support for DbContext (EF v4.1/EF v4.2): http://blogs.msdn.com/b/adonet/archive/2011/03/02/ef-4-1-is-coming-dbcontext-api-amp-code-first-rtw.aspx . Probably, you are working with DbContext.

In case of Entity Framework June 2011 CTP, it is possible to avoid an explicit compilation because auto-compiled LINQ queries are implemented in EF June 2011 CTP: http://blogs.msdn.com/b/efdesign/archive/2011/06/30/auto-compiled-linq-queries-entity-framework-june-2011-ctp.aspx .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文