【问题标题】:Is there a way to set an SQL comment from an IQueryable?有没有办法从 IQueryable 中设置 SQL 注释?
【发布时间】:2019-05-25 09:30:15
【问题描述】:

ICriteriaSetComment(),但我没有看到 IQueryable 的可比性。

【问题讨论】:

    标签: nhibernate iqueryable icriteria


    【解决方案1】:

    在 NHibernate 5+ 中,WithOptions 扩展方法允许设置一些特定于查询的选项,例如超时、缓存选项和 cmets。

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

    您可能需要导入 NHibernate.Linq 命名空间。

    【讨论】:

    • 非常感谢。我想我必须升级到 NH5 才能尝试一下。也许本周晚些时候......
    猜你喜欢
    • 2017-06-03
    • 1970-01-01
    • 1970-01-01
    • 2022-01-14
    • 2013-11-13
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 1970-01-01
    相关资源
    最近更新 更多