Interesting VB.Net Snippets

time to read 2 min | 266 words

I using auto convertion to move code from C# to VB.Net, and I just run into this tidbit.

Public Shared Widening Operator CType(ByVal expr As QueryBuilder(Of T)) As DetachedCriteria

Widening? Apperantly there is also Narrowing operator. I'm not sure how they relate to the actual operation performed, though.

But perhaps the best looking piece of code is this one:

Post.FindOne( Where.Post.Blog Is Nothing )

Yes, this is real code. VB 2005 and NHibernate Query Generator. Even if we don't ignore LINQ, this is the most precise looking code that I have seen for querying. And yes, this does what you expect it to.