0

I've spent the entire day trying to convert this VB.Net code into SQL script. The goal is to remove the VB code and switch to stored procedures:

Dim hashmap = getHashMap()
Dim x = hashmap.Where(Function(i) Not i.Name.ToLower.Contains("john"))
Dim y = x.GroupBy(Function(i) i.City)
Dim z = y.Select(Function(grp) grp.First()).ToList

So far, I've translated everything but the last line (Dim z = y.Select(Function(grp) grp.First()).ToList):

SELECT City FROM hashmap WHERE LOWER(Name) NOT LIKE '%john%' GROUP BY City
Talenel
  • 422
  • 2
  • 6
  • 25
RAFJR
  • 362
  • 1
  • 7
  • 22
  • So what is the problem? exception message? wrong result? – Fabio Jul 20 '17 at 05:19
  • I've translated everything but the last statement (y.Select(Function(grp) grp.First()).ToList) to SQL – RAFJR Jul 20 '17 at 09:31
  • It is easier to write SQL off a description of what the code needs to achieve rather than off actual code. As far as I understand the code returns one random hasmap value per city. If that is the case, you want to see e.g. https://stackoverflow.com/q/12113699/11683, https://stackoverflow.com/q/19168834/11683 or https://stackoverflow.com/q/2129693/11683. – GSerg Jul 20 '17 at 09:51
  • You're right. Sometimes the most challenging requirement is "Make it work as it is working today". – RAFJR Jul 21 '17 at 01:42

0 Answers0