1

After some digging I found that the reason the following NHibernate query

  IList<User> users = session.QueryOver<User>()                        
            .WhereRestrictionOn(user => user.EmployeeID)
            .IsInG<string>(new string[] {EmployeeID.ToUpper()})
            .List<User>();

was not working in an Oracle was that I did not set the property in the mapping as "AnsiString". i.e.

 <property name="EmployeeID" column="LAN_ID" type="AnsiString" /> 

Can someone tell me why this has to be done? The underlying datatype in Oracle is varchar2

2 Answers 2

2

Actually Ricardo you are wrong. VARCHAR and VARCHAR2 are the same, but using VARCHAR2 is recommended. NVARCHAR2 is the unicode type. Check out: http://docs.oracle.com/cd/B19306_01/server.102/b14220/datatype.htm#i3253

So my guess is - if you are using VARCHAR2 you need AnsiString in your NHibernate mapping. Otherwise, it defaults to Unicode strings. If you don't specify AnsiString and you have VARCHAR2 mapped column, there are more problems then just "ToUpper" issue. Oracle will have to do type conversion and will not be able to use index in searches.

I hope it helps!

Sign up to request clarification or add additional context in comments.

Comments

0

AnsiString = VARCHAR = ANSI (not UNICODE) String = VARCHAR2 = UNICODE

You must have something else wrong, I guess.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.