I was looking for linq to entities extension which allows to add OPTION(MAXDOP x) to the query generated. For queries I want to limit their SQL Server resources.
Something like:
Customers.WithMaxDop(2).Where(...) ..
Couldn't find. Before I try to dig-in to create my own extension I wanted to ask you guys first for help - how would you suggest to do so?
Thanks!
That is query hint which cannot be added by extension method. You must either build whole new EF provider or wrap the query with the hint into database view and map the view as the new read only entity.
EF is abstraction on top of database (theoretically any database) - it is not supposed to offer you control over such DB details. If you want these details you must code them on database layer and only expose views or stored procedures to EF.