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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...