problems with StartsWith / EndsWith / Contains / Substring / IndexOf

Description

My mapping is

LINQ:

SQL:

LINQ:

SQL:

LINQ:

=> The where clause in all cases above should be 'where order0_.[CODE] like @p0', and @p0 = '%001%' / @p0 = '001%' / @p0 = '%001' , the one will gain more performance when the query above run many times.
=> StartsWith/EndsWith/Contains methods can reuse the same SQL Execution Plan by database engine

LINQ:

SQL:

=> The where clause should be 'where length(order0_.[CODE]) >= (@p0 + @p1) and substring(order0_.[CODE], 0, 1) == 2'

Environment

None

Activity

Show:

Frédéric Delaporte 
June 19, 2020 at 5:40 PM

Moved here.

This behavior will not be changed by default in NHibernate, because it may cause re-use of inadequate query plans, as commented on #725 and in #2396

But in v5.3, a new configuration option will allow to add custom rewriters in order to adjust the Linq expression.

See detail on the GitHub transfered issue

Alex Zaytsev 
January 23, 2013 at 3:06 AM

I think it is possible to make new ExpressionType to handle this.

Oskar Berggren 
April 5, 2012 at 4:02 PM

Could you please check if these problems persist in 3.3.0CR1?

Fabio Maulo 
September 7, 2010 at 9:19 AM

1. The Linq-provider is available only in NH3.
2. Ok in case of constant-parameter

Won't Do

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created September 7, 2010 at 3:18 AM
Updated June 19, 2020 at 5:40 PM
Resolved June 19, 2020 at 5:40 PM
Who's Looking?