Replace SQL CONTAINS as an expression?

I have a question. I am working on a single site on Asp.Net that uses some ORM. I need to use several FullTextSearch functions like Contains. But when I try to generate it using this ORM, it generates such SQL code

SELECT [Extent1].[ID] AS [ID], [Extent1].[Name] AS [Name] FROM [dbo].[SomeTable] AS [Extent1] WHERE (Contains([Extent1].[Name], N'qq')) = 1 

SQL cannot parse it because Contains does not return a bit value. And, unfortunately, I cannot change the process of generating SQL queries, but I can change the instructions in it.

My question is: is it possible to transfer the CONTAINS function call to something else? I tried to create another function that will contain SELECT with contains, but this requires specific table \ column objects, and I do not want to do one function for each table.

EDIT

I can change the result type for this function in ORM. In the previous example, the result type is bit. I can change it to int, nvarchar, etc. But, as I understand it, in SQL there is no Boolean type, and I can not specify it.

+4
source share
1 answer

Can you put this in a stored procedure and tell ORM about the call to the stored procedure? Then you need not worry that your ORM only understands a subset of valid T-SQL.

I do not know that I believe that an argument requiring new stored procedures is a blocker. If you need to write a new CONTAINS expression in your ORM code, how different is its transfer in the CREATE PROCEDURE statement in another window? If you want to do this exclusively in ORM, then you will have to put pressure on the seller to increase the pace and begin to more fully cover the language that they must fully support.

+2
source

Source: https://habr.com/ru/post/1402773/


All Articles