views:

29

answers:

2

I'm in a situation where I want to add the equivalent of the sql statement

SET QUERY_GOVERNOR_COST_LIMIT

to my query I created with linq to entities.

How would I go about that?

A: 

You can create a connection yourself, execute the statement, wrap the connection in a EntityConnection and that as parameter to the ObjectContext constructor. This way the ObjectContext is executed within the context of that connection.

Steven
We wanted to do such a thing, but we get our context from a factory. The factory is out of scope. Is there another way to execute the sqlCommand on the (existing) context's conncetion somehow?
borisCallens
A: 
var conn = ((EntityConnection)Context.Connection).StoreConnection;

Also, in EF 4 you can do Context.ExecuteStoreQuery

Craig Stuntz
Though rather verbose, this was indeed what we used.Sadly it appeared not to be core issue.
borisCallens