有没有办法在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