-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad SQL #20
Comments
What is wrong with this SQL? |
Sql Server says: Msg 156, Level 15, State 1, Line 13 В этом запросе ему не нравится вложенное условие like |
What SQL do you expect? |
SELECT
[it].[Name],
[it].[Type] as [Type1],
[it].[Chief_Id],
[it].[Parent_Id],
[it].[Id]
FROM
[Departaments] [it]
WHERE
CASE
WHEN CASE
WHEN [it].[Name] IS NULL THEN NULL
when [it].[Name] LIKE N'КИ%' then 1
END IS NULL
THEN 0
WHEN [it].[Name] IS NULL THEN NULL
when [it].[Name] LIKE N'КИ%' then 1
END = 1 In SQL Server 2012 exists IIF function http://msdn.microsoft.com/en-us/library/hh213574.aspx |
Who implemented conversion of the IIF function to SQL? |
IIF in linq query ConditionalExpression. |
From your example |
This LINQ query restored from Expression. IIF not function, is text view ConditionalExpression.
Данный запрос формируется кодом WCF Data Services, поэтому мне пришлось его востанавливать из выражения. Думал что IIF это встроенная функция и не стал ее подменять. Ваши вопросы потребовали более глубокого изучения вопроса. Оказалось что IIF это текстовое представление выражения типа ConditionalExpression, что доказывает код выше. |
For query:
result SQL:
This query build WCF Data Services for uri: http://localhost:50089/ricService.svc/Departaments?$filter=startswith(Name,'%D0%9A%D0%98')
The text was updated successfully, but these errors were encountered: