Calling the .Equals method on a string generates a like query as you discovered. If you want to generate a SQL =, just do: p.Email == userEmail
As Fabio pointed out, I am not aware of any case-insensitive search in SQL server. It is all case-insensitive by default. On Tue, Mar 31, 2009 at 9:14 AM, Fabio Maulo <[email protected]> wrote: > which is the SQL for caseInsensitive. > > 2009/3/31 Robert Misiak <[email protected]> > >> >> I am working on a project in which we're using session.Linq<T>() to do >> a variety of searches using Lambda expressions. We don't even have >> nHibernate exposed to our application - we have a service layer with >> methods that take Expression<Func<T, bool>> as a parameter which call >> session.Linq<T>() with the passed parameter. >> >> We have a large table which was performing very slowly, and our DBA >> found the nHibernate was doing a SQL LIKE behind the scenes instead of >> using "=" which was a contributor to the slow performance. The Lambda >> expressions that were getting converted to a LIKE were like so: >> >> session.Linq<T>(p => p.Email.Equals(userEmail, >> StringComparison.InvariantCultureIgnoreCase)); >> >> This leads me to the following questions: >> >> 1. What is the preferred way to do a case-insensitive search using >> nHibernate.Linq? >> 2. Is this a bug or a feature? Are there any plans to change this >> behavior in the future? >> >> I think that it would be helpful if in future versions of >> nHibernate.Linq, behavior related to case-(in)sensitivity or using SQL >> LIKE was more transparent to the developer. >> >> FYI, in the mean-time, we've switched most of our simple queries to >> use CreateCriteria(). >> >> Regards, >> Robert Misiak >> >> >> >> > > > -- > Fabio Maulo > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NHibernate Contrib - Development Group" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com.ar/group/nhcdevs?hl=en -~----------~----~----~----~------~----~------~--~---
