nhibernateiqueryableicriteria

Is there a way to set an SQL comment from an IQueryable?


ICriteria has SetComment(), but I see nothing comparable for IQueryable.


Solution

  • In NHibernate 5+ there is WithOptions extension method that allows to set some query specific options like timeouts, cache options, and comments.

    var query = (
        from e in session.Query<YourEntity>()
        select e
    ).WithOptions(o => o.SetComment("Your comment"));
    

    You might need to import NHibernate.Linq namespace.