Should I tell NHibernate/FNH to explicitly use a string data type for a param mapped to a string column? -


Using one of my groups, the user is making a few long search queries based on different inputs. We have been mapped NHibernate via Fluente Nibbernet, and apart from some minor mistakes, all are running well.

One issue we can not solve in this search case is that the special parameter is creating NHibernate SQL which treats the input as an int when we have a clear string is needed. We have mapped string properties in a nvarchar (255) column, which contains most integer numbers, such as "temporary" or long number such as 4444444444444444 which is beyond the int range.

In the test, I have seen a few things: 1) If I put 0 for the incoming value, then the NAH generates SQL param as a string; 2) If the value can be actually converted to an integer, then the resultant SQL behaves in the same way. In the case of # 2, if I run the generated SQL directly through the SQL server, then I get an exception when There is a query on a non-integer value (i.e. the example listed above). For some reason, when I just let NH to do this, I'm getting the proper record back, but it does not understand; I hope this will fail or at least tell me that there is something wrong with some records which can not be evaluated by SQL Server.

Mapping is simple, data store is simple; I would have to remain alone enough to be properly enough if I at least understand why / NHibernate it is working when the same situation fails manually ... Any thoughts? Post-text "itemproc =" text ">

Are you running the same code directly in SQL Server?

NHibernate parameterizes all of your queries, and by doing so, What value is passed through the SQL in that parameter is possible what you are asking about, the cause of the SQL is my failure, by default it can only detect the difference if you input :

  select * t Choose from table_name with the help of 'where_name =' 5 ' 
with col_name = 5

  

If you do not define it with a string it will search an int, and try to convert all varchar into ints, which will obviously fail in some cases with the wire.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -