This will result in the same thing as with a variable. If it is a non zero leading number, it will strip the quotes. If it is not a number, or a zero leading number, it will keep the quotes.
I could write a test that looks much like below, but I don't have the first inkling on how to assert if the generated query has quotes or not :( If i did, i would write the test to include scenarios with: 1) string that happens to be a number 2) string that is a number but has a leading zero 3) string that is not a number 4) string that has both numeric and non numeric characters thanks for your help with this Jose, Ralph On May 20, 6:39 pm, José F. Romaniello <[email protected]> wrote: > wondering what hapen if you query something like this: > > using (var tx = session.BeginTransaction()) > { > census = session.CreateCriteria(typeof(Census)) > .Add(Restrictions.Eq("SSN", "abcd12333")) > .UniqueResult<Census>(); > tx.Commit(); > } > does it fails? does it use a string instead of int parameter? > > Anyway, send a small test case here:http://jira.nhforge.com/ > > 2011/5/20 Ralph Balck <[email protected]> > > > > > > > > > the query I'm copying from NHProf is like your second example using > > @p0 = 123456789 or @p= '123456789' > > > i set the sqltype as nvarchar(9) in the mapping file and I'm still > > getting the same result. I tried nvarchar as well. I even changed > > the type in the db to char(9) and used that in the mapping file. No > > combination of data types and length specifications seems to change > > the behavior. > > > I can't help but think NHibernate is trying to be too cleaver here, by > > looking to see if this is a number and not quoting it. I can see > > where that helps if you are querying a number column, but it is > > causing the CONVERT_IMPLICIT issue when the underlying column is a > > character data type. I wonder if there is a flag somewhere to turn > > off the thing that is unquoting this string? > > > Ralph > > > On May 20, 11:18 am, José F. Romaniello <[email protected]> > > wrote: > > > 2011/5/20 Ralph Balck <[email protected]> > > > > > <property name="SSN" type="System.String, mscorlib, > > > > Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> > > > > <column name="SSN" /> > > > > </property> > > > > can you show us exactly the loging result... because nhibernate doesn't > > > execute this: > > > select * from Census where SSN=265145847 > > > > it might be something like: > > > select .... from ... where SSN = @p0 ; @p0 = .... > > > > the problem, i see is that > > > 1-you don't have the lenght of the column > > > 2- you would probably need to use <column name="SSN" > > sql-type="nvarchar(8)" > > > /> > > > > but try first 1. > > > Maybe you see is a CONVERT_IMPLICIT because is converting a varchar > > > parameter to a nvarchar column.. or different sizes. > > > Not quite sure what is going on... > > > -- > > 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. -- 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.
