Linqer won't do this SQL.. :(

情到浓时终转凉″ 提交于 2019-12-11 13:15:39

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/4291293/linqer-wont-do-this-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!