EF CodeFirst with ESQL
-
Saturday, January 22, 2011 12:28 PM
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?
All Replies
-
Tuesday, January 25, 2011 7:59 PMModerator
Hi,
You can drop down to the underlying ObjectContext to run ESQL queries:
((IObjectContextAdapter)myContextInstance).ObjectContext.CreateQuery<MyEntity>("<ESQL Query>")
~Rowan
- Proposed As Answer by Rowan MillerMicrosoft Employee, Moderator Tuesday, January 25, 2011 7:59 PM
-
Wednesday, January 26, 2011 7:42 AM
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 -
Friday, January 28, 2011 7:31 PMModerator
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, March 18, 2011 7:46 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
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
-
Thursday, March 24, 2011 5:46 PMModerator
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

