linq-to-sqllinqer

Linqer won't do this SQL.. :(


I have this quick query but since my table is named User (SQL keyword), Linqer (a SQL to LINQ converter) fails to convert the SQL query.

Here is the query:

SELECT TOP (100) PERCENT
  dbo.[User].OID,
  dbo.[User].FirstName + ' ' + dbo.[User].LastName AS [User Name],
  COUNT(dbo.AssignedCounty.OID) AS [Counties Assigned],
  dbo.UserType.Name AS [User Type]
FROM
  dbo.UserType
  INNER JOIN dbo.[User] ON dbo.UserType.OID = dbo.[User].UserTypeID
  LEFT OUTER JOIN dbo.AssignedCounty ON dbo.[User].OID = dbo.AssignedCounty.UserID
GROUP BY
  dbo.[User].OID,
  dbo.[User].FirstName + ' ' + dbo.[User].LastName,
  dbo.UserType.Name,
  dbo.[USER].IsActive
HAVING
  (dbo.[User].IsActive = 1)
ORDER BY
  [User Name]

Can anyone guide me on how to work my way around this? I need the LINQ.

LINQ me


Solution

  • Apparently, using keywords as Table/Column names is a very bad habit. The User/Users is a keyword in SQL Server. In addition, the joins are jumbled up and Linqer or SQL Metal cannot process them however, LinqPad was able to understand the query but since it is not a conversion tool, does me no good. I finally did a massive renaming operation and most of my failing queries just started to work again. User -> SystemUser