Step by step you will see how we will give the ability to extend our Linq-Provider giving you the way to inject the translation of your own LINQ-extension-methods. Doing so, *you* can implement a string extension named Like, working in RAM, and can be translated to SQL.
Hopefully, in this way, all users can find his own way to translate StartsWith, EndsWith, Length, Count(), Count, and so on and perhaps somebody will share his solution in the same way they share his opinion. On Wed, Jul 28, 2010 at 12:41 PM, Wenig, Stefan <[email protected]>wrote: > > -----Original Message----- > > From: [email protected] [mailto:nhibernate- > > [email protected]] On Behalf Of Frans Bouma > > > > Good point you brought up here. I can imagine escaping is the > > reason > > why the '%' is separated (I asked a question about this, but it's not > > answered) along the way, so you can do simple escaping without running > > the > > risk of escaping the '%' character as well. The problem is though that > > the > > '%' is separated in the _query_, which is odd, as I assume the specific > > AST > > part, namely the LIKE expression part, is handled by a method which > > only > > emits like fragments, and thus knows how to append the '%' after it > > produces > > the escape line. > > Too many assumptions for me to follow up on, someone from the NH team would > have to weigh in here (if they want). > For me, it would be much easier to follow this if I could see the interim > HQL. As things are now, I often cannot tell whether something is rooted in > LINQ to HQL or in HQL to SQL. > I just asked Steve, he said he could do it quite easily (but didn't say if > he actually will ;-)) > > > > > Not all databases support the same escaping btw (or at all), so > > this > > might be a dialect specific feature. > > I believe LIKE '100\%%' ESCAPE '\' to be ANSI SQL. Differences exist of > course, such as the regex-like [...] in TSQL. > > http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt > > 8.5 <like predicate> > > Function > > Specify a pattern-match comparison. > > Format > > <like predicate> ::= > <match value> [ NOT ] LIKE <pattern> > [ ESCAPE <escape character> ] > -- Fabio Maulo
