如何获取LinqToSql为“索引提示”传递给SQL Server? [英] How do I get LinqToSql to pass “index hints” to sql server?

查看:159
本文介绍了如何获取LinqToSql为“索引提示”传递给SQL Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我们不能相信我们的客户更新索引统计信息等在SQL Server中,我们在过去不得不使用的索引提示的。 (由于我们的一些客户仍然在SQL Server 2000中,我们也可以不依赖于在以后的SQL Server版本更好的查询优化器)。

As we can’t trust our customers to update the index stats etc in sql server, we have in the past had to use index hints. (As some of our customers are still on Sql Server 2000, we also can’t depend on the better query optimizer in later version of Sql Server).

那么,如何传递索引提示使用LinqToSql建立一个查询,而不是原始的SQL当?

So how do I pass in index hints when using LinqToSql to build a query rather than raw Sql?

推荐答案

这是不被支持的东西,你只能在一个查询选项是将事务隔离级别设置,但这并不能帮助解决这个问题。

This is not something that is supported, you only options over a query is to set the transaction isolation level, but that doesn't help with this issue.

我会建议的行动两门课程之一,这是东西,你真正需要做的。

I would recommend one of two courses of action is this is something that you really need to do.

  1. 您可以编写一个存储过程,你的过程中对此进行处理并使用LINQ来称呼它......

  1. You can write a stored procedure and handle this within your procedure and use LINQ to call it....

请远离LINQ到SQL

Move away from LINQ to SQL

就个人而言,如果这是真的有需要我会推荐方案二。事实上,如果你必须采取行动/控制,该级别在你的数据库调用,自动生成的SQL将是有问题的,你在稍后的积分。

Personally, IF this is really necessary I would recommend option two. If in fact you must take that level of action/control over your database calls, auto-generated SQL is going to be problematic for you at later points as well.

这篇关于如何获取LinqToSql为“索引提示”传递给SQL Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆