Hello, I would like to know how to view the sql code that a linq expression generates to be run by ADO.Net.
I'm using NHibernate as an ORM framework.
Hello, I would like to know how to view the sql code that a linq expression generates to be run by ADO.Net.
I'm using NHibernate as an ORM framework.
Make a function like this
public string GetGeneratedSql(System.Linq.IQueryable queryable, ISession session)
{
var sessionImp = (ISessionImplementor) session;
var nhLinqExpression = new NhLinqExpression(queryable.Expression, sessionImp.Factory);
var translatorFactory = new ASTQueryTranslatorFactory();
var translators = translatorFactory.CreateQueryTranslators(nhLinqExpression, null, false, sessionImp.EnabledFilters, sessionImp.Factory);
return translators[0].SQLString;
}