C# NHibernate在查询时指定索引

C# NHibernate在查询时指定索引,c#,nhibernate,C#,Nhibernate,我想为下面的sql查询创建Nhibernate C查询 SELECT ContactID FROM Person.Contact WITH (INDEX(AK_Contact_rowguid)) GO 如何执行此操作?您需要使用methode.CreateSqlQuery,例如: var SessionFactory=Configuration.BuildSessionFactory; ISession session=SessionFactory.OpenSession session.Cr

我想为下面的sql查询创建Nhibernate C查询

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

如何执行此操作?

您需要使用methode.CreateSqlQuery,例如:

var SessionFactory=Configuration.BuildSessionFactory; ISession session=SessionFactory.OpenSession session.CreateSQLQuerySELECT ContactID FROM Person.Contact WITH INDEXAK_Contact_rowguid

有关更多信息,请查看此