-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NHibernate Linq orderby ignore case
PostPosted: Thu Jan 14, 2010 6:16 am 
Newbie

Joined: Thu Jan 14, 2010 5:13 am
Posts: 1
Hello,

i have a strange Problem and can't find anything on the internet and in this forum about it.

My Select is pretty easy. All i want is a query with an orderby name, which is case insensitive. Like "Select * from tbl order by UPPER(column);"

My first guess was this, but i alwas get an IndexOutOfBounds Exception
Code:
        var query = from o
                         in session.Linq<OrganisationalUnit>()
                         orderby o.Name.ToUpper()
                         select o;
       retun query.ToList();

The second try was
Code:
        var query = from o
                         in session.Linq<OrganisationalUnit>()
                         select o;
       return query.OrderBy(p => p.Name, StringComparer.CurrentCultureIgnoreCase).ToList();

Again an exception.

This would work. But there has to be a better way:
Code:
        var query = from o
                         in session.Linq<OrganisationalUnit>()
                         select o;
       return query.ToList().OrderBy(p => p.Name, StringComparer.CurrentCultureIgnoreCase).ToList();

Or is there a complete different way to do an select which is case insensitive, and I'm completely wrong? Thank you for your help.

Regards,

MoJo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.