NHibernate指定查询索引

时间:2018-07-29 11:00:40

标签: c# nhibernate

我想为以下sql查询创建Nhibernate C#查询,

SELECT ContactID
FROM Person.Contact WITH (INDEX(AK_Contact_rowguid))
GO

我该怎么做?

1 个答案:

答案 0 :(得分:0)

您需要使用方法.CreateSqlQuery()这样的示例:

var SessionFactory = Configuration.BuildSessionFactory(); ISession session = SessionFactory.OpenSession() session.CreateSQLQuery("SELECT ContactID FROM Person.Contact WITH (INDEX(AK_Contact_rowguid))");

有关更多信息,请检查此link