Question

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,

Was it helpful?

Solution

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 .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top