none
EF CodeFirst with ESQL

    Question

  • We have developed the Linq to ESQL function to send the serilize dynamic quires across the WCF.

    Is it is possible to use ESQL queries with EF CodeFirst?

    Saturday, January 22, 2011 12:28 PM

All replies

  • Hi,

    You can drop down to the underlying ObjectContext to run ESQL queries:

    ((IObjectContextAdapter)myContextInstance).ObjectContext.CreateQuery<MyEntity>("<ESQL Query>")

    ~Rowan

    Tuesday, January 25, 2011 7:59 PM
    Moderator
  • It would be nice to support atleast builder methods on the DbSet lot of times they are useful to build dynamic queries. For instance something like this should be supported

    db.Customers.Where("it.City = @city","London");

     


    Zeeshan Hirani Entity Framework 4.0 Recipes by Apress
    http://weblogs.asp.net/zeeshanhirani
    Wednesday, January 26, 2011 7:42 AM
  • Hi Zeeshan,

    ESQL was something we decided not to expose in the DbContext API because we see it as an advanced scenario that shouldn't get in the way of folks seeing the API for the first time. This is obviously a judgement call and one could argue either way, it's certainly something we could add in the future if we see a lot of asks for it.

    ~Rowan

    Friday, January 28, 2011 7:31 PM
    Moderator
  • Hi Zeeshan,

    ESQL was something we decided not to expose in the DbContext API because we see it as an advanced scenario that shouldn't get in the way of folks seeing the API for the first time. This is obviously a judgement call and one could argue either way, it's certainly something we could add in the future if we see a lot of asks for it.

    ~Rowan

    And what about folks seeing the API every day from CTP3? :-/

    We should drop DbContext and start using ObjectContext becouse of ESQL? It would be nice to have global "where" (Role Management...) in string, thats possible with esql, but with IQueryable? That means every single lambda bypassed to ObjectQuery with Load() on end or some master-blaster apparatus for translating strings to lambda expression... yuck

    Friday, March 18, 2011 7:46 AM
  • Hi Splite,

    You don't need to drop DbContext to use ESQL, you just need to drop down to the ObjectContext that is backing your DbContext.

    ((IObjectContextAdapter)myContextInstance).ObjectContext.CreateQuery<MyEntity>("<ESQL Query>")

    ~Rowan

    Thursday, March 24, 2011 5:46 PM
    Moderator