私はLinqをNHibernateに使用しています。
私は次のテストケースを持っています:
[TestMethod]
[DeploymentItem("hibernate.cfg.xml")]
public void Category_Should_GetAllByLinq()
{
// Arrange
IRepository<Category> repo = new CategoryRepository();
//Act
IList<Category> list = repo.GetListByLinq();
//Assert
Assert.IsTrue(list.Count > 0);
}
また、CategoryRepositoryクラスに次のコードがあります。
public IList<Category> GetListByLinq()
{
ISession session = NHibernateHelper.OpenSession();
// When following statement is executed, How to check converted real sql query?
var query = from c in session.Linq<Category>()
select c;
return query.ToList();
}
私の質問は、linq to nhibernateステートメントが実行されると、実際に変換されたSQLクエリをチェックする方法は?何か方法はありますか?
SQLプロファイラーを使用できることはわかっていますが、テストケースでモックオブジェクトを使用したいので、データベース関連のメソッドで表示したくありません。