yessql icon indicating copy to clipboard operation
yessql copied to clipboard

SQL Server translation issue

Open brunoAltinet opened this issue 2 years ago • 0 comments

This type of query

var includeDraft = true;
_session.Query<ContentItem, UserPickerFieldIndex>(x => (x.Published || includeDraft));

Gets translated in SQL Server into

exec sp_executesql N'SELECT DISTINCT [Document].* FROM [Document] INNER JOIN [UserPickerFieldIndex] AS [UserPickerFieldIndex_a1] ON [UserPickerFieldIndex_a1].[DocumentId] = [Document].[Id] WHERE (([UserPickerFieldIndex_a1].[Published] = @p1) or @p2)),@p1 bit,@p2 bit,@p1=1,@p2=1

The issue is that @p2 by itself wont fly in sql server, it has to be compared to 1 It's stupid i know, but needs some dialect work. Can be worked around but just so you know the issue exists

brunoAltinet avatar Oct 20 '21 13:10 brunoAltinet