VB.NET中的内联LINQ注释

有没有办法在VB.NET中的LINQ中插入内联代码注释?

请参阅下面的第2行,作为需要内联注释的示例

Dim Jobs = (From X In DB.Jobs_Select(SearchStr,RequiresFilter)
    Where X.JobStatusID < 2   -- **** INSERT INLINE COMMENT HERE  ****
    Order By
        X.JobPriorityID Descending,If(X.TargetDate,Date.MaxValue),X.NeedsLit Descending,X.HasOldArtRequests Descending,X.HasOldLicRequests Descending
    )

这在SQL代码中是微不足道的,坦率地说,当SP变得复杂时非常有用.能够在LINQ to SQL中执行相同的跨开发人员通信会很高兴.

更新

这是您的测试条件.

Dim L As New List(Of KeyValuePair(Of Integer,Integer))

 Dim a = (From X In L
            Where X.Key > 5 'test comment
            Order By X.Value)

解决方法

好的伙计,这是官方的答案 – 在VB中不可能. Proof.

It is REALLY annoying in VB that you cannot add inline comments to
multiline LINQ statements!

更多信息:

The bad news is that this wouldn’t be trivial to implement.
Limitations about single-lines and comments are built into the current
VB parser at too low a level. It’d require a complete rewrite of the
VB parser.

The good news is that we’ve embarked upon such a rewrite (codenamed
“Roslyn” — there have been several articles and talks about it). It’s
still a way off and we’re not making commitments about what/when at
this stage.

— Lucian Wischik,VB language PM

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐