ICriteria criteria = s.CreateCriteria(typeof (TreeNode))
.Add(
Restrictions.Eq(
Projections.SqlFunction("upper",
NHibernateUtil.String,
Projections.Property("Name")), "BAR"));
or
ICriteria criteria = s.CreateCriteria(typeof (TreeNode))
.Add(
Restrictions.Eq(
Projections.SqlFunction(Dialect.Functions["upper"],
NHibernateUtil.String,
Projections.Property("Name")), "BAR"));
or
var sqlFunction = new StandardSQLFunction("upper", NHibernateUtil.String);
ICriteria criteria = s.CreateCriteria(typeof (TreeNode))
.Add(
Restrictions.Eq(
Projections.SqlFunction(sqlFunction,
NHibernateUtil.String,
Projections.Property("Name")), "BAR"));
or
ICriteria criteria = s.CreateCriteria(typeof (TreeNode))
.Add(
Restrictions.Eq(
Projections.SqlProjection("upper(Name) as dummy_not_important", new[] {
"dummy_not_important" }, new[] { NHibernateUtil.String }), "BAR"));
Choose whichever you like. In case you are using oracle, i suggest you to
create your own Dialect (inheriting the original oracle dialect) and add the
functions you like, and which are not already registered, there, and use the
1st or the 2nd one.
Tuna Toksöz
Eternal sunshine of the open source mind.
http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike
On Fri, Jul 17, 2009 at 12:30 AM, Tuna Toksoz <[email protected]> wrote:
> isn't SQL case-insensitive?
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksoz
> http://tunatoksoz.com
> http://twitter.com/tehlike
>
>
>
>
>
> On Thu, Jul 16, 2009 at 10:57 PM, Colin Bowern <[email protected]> wrote:
>
>>
>> How would one do an UPPER(Foo) = 'BAR' criteria in NHibernate (not
>> using HQL) using criteria.Add(....)?
>>
>> Thanks,
>> Colin
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" 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/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---