title: Need to convert SQL Query to LINQ
body: <p>I have the following SQL query that I need to convert into LINQ with VB.NET </p>
  
  <pre><code>SELECT *
  FROM    (SELECT Id
           ,LocationCode 
           ,LocationName
           ,ContactName
           ,ContactEmail
           ,Comments
           ,SBUName
           ,CreatedBy
           ,CreatedDtm
           ,ModifiedBy
           ,ModifiedDtm
           ,ROW_NUMBER() OVER (PARTITION BY LocationCode ORDER BY ID) AS RowNumber
  FROM testDB ) as rows
    WHERE ROWNUMBER = 1
  </code></pre>
  
  <p>There are many duplicates of location code so I only want to display one record of each and the user will be able to edit the information. Once they edit I will save the info for all records that are for that specific location code.</p>
  
  <p>I couldn't use <code>DISTINCT</code> here, it would still bring back all of the data since the <code>CreatedBy</code>/<code>ModifiedBy</code> are different.</p>
  
  <p>By using the following LINQ query to select all of the data, is there a way I can get the DISTINCT records for <code>LocationCode</code> out of it?</p>
  
  <pre><code>queryLocMaint = From MR In objcontextGSC.TestDB
                                  Select MR.Id,
                                      MR.LocationCode,
                                      MR.LocationName,
                                      MR.SBUName,
                                      MR.ContactName,
                                      MR.ContactEmail,
                                      MR.Comments,
                                      MR.CreatedBy,
                                      MR.CreatedDtm,
                                      MR.ModifiedBy,
                                      MR.ModifiedDtm()
  </code></pre>