I’ve recently discovered that LINQ and VB can be confusing. I was attempting to pull the top 10 rows of a table where the column started with ‘W’. You’d think after I typed that, I’d figure out the solution. That’s not the case. Instead, I struggled. Here’s what I originally came up with:

1
Dim q = From t In db.Employees Where t.LastName Like prefixText & "%" Select t.LastName Take count

Little did I realize that the Like operator in my query was the VB Like operator. So, I had to modify my lambda expression to this:

1
Dim q = From t In db.Employees Where t.LastName.StartsWith(prefixText) Select t.LastName Take count

You’ll notice that StartsWith makes more sense. <sigh> If only VB were…