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.  [ 2 posts ] 
Author Message
 Post subject: Mapping to Dictionary with CurrentCultureIgnoreCase
PostPosted: Thu Feb 14, 2008 10:20 pm 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:06 pm
Posts: 28
I have run into an issue mapping a dictionary to the DB where it is important that the dictionary keys use case-insensitive comparisons when checking for entries in the dictionary. The problem is that SQL server does perform case-insensitive comparisons when checking PK contraints but a default generic dictionary does not.

I need my dictionaries to behave like SQL server, so when I create them, I use the following...

IDictionary<string, string> _dataValues = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);

So...

_dataValues.Add("APPLE", "RED"); // No problem.
_dataValues.Add("GRAPE", "PURPLE"); // No problem.
_dataValues.Add("Apple", "ALSO RED"); // EXCEPTION.

This is what I want. The problem is that when my objects are re-hydrated by NHibernate, they are placed into a dictionary that used the default string comparer, which is case-sensitive, and will allow the above operation.

Does anyone have any idea on how I can tell NHibernate to use CurrentCultureIgnoreCase as the comparer?

Thanks!


Top
 Profile  
 
 Post subject: Re: Mapping to Dictionary with CurrentCultureIgnoreCase
PostPosted: Fri Feb 22, 2008 11:59 am 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:06 pm
Posts: 28
Does anyone have any suggestions or insight into this issue?


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

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.