How can I specify an index hint in Entity Framework?

后端 未结 2 1736
慢半拍i
慢半拍i 2020-12-15 08:01

sql

select * from table1 with(index=IX_table1_1)

Linq to sql using ado.net entity would like to write the above code. I could not find en

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 08:43

    Neither L2S nor EF will provide direct support for SQL as bespoke as that (index hints, etc), although with L2S you can achieve it via ExecuteQuery(...) (which takes raw TSQL). If you need that level of control, consider either stored procedures or an alternative ORM.

    One problem in particular here is that query hints are pretty platform specific, but EF tries to be platform-neutral.

提交回复
热议问题