Nhibernate formula adding a pattern word to sql keyword

I use the following formula in the mapping file:

select top 1 SI.ID from the SI table with (nolock), where SI.GUID = GUID AND SI.IsArchive = '0'

genrated sql: select top 1 SI.ID from the SI table with (this_.nolock) , where SI.GUID = this_.GUID AND SI.IsArchive = '0'

Knock is a keyword. I do not want this to match this _ (keyword template).

How can I change this behavior?

+3
source share
2 answers

(, sql ) . .

:

    CREATE FUNCTION [dbo].[GetMyValue] ( @entityId INT ) 
    RETURNS INT
    AS BEGIN
      DECLARE @RtnValue AS INT 
      SELECT @RtnValue = top 1 SI.ID from Table SI with(nolock) where SI.id = @entityId AND SI.IsArchive = '0'
      RETURN @RtnValue
    END

formula="dbo.GetMyValue(id)"

.

0

, nhibernate; :

<property name="hibernate.query.substitutions">mynolock nolock</property>

:

select top 1 SI.ID from Table SI with(mynolock) where SI.GUID = GUID And SI.IsArchive = '0'
0

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


All Articles