liubiao4123 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

Parser Error in ServiceStack.OrmLite.SqlServer.SqlServerOrmLiteDialectProvider #35

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create a SQL-Server 2008 table with a "bit" column
2. in your object map this column to "bool"
3. read a record from the table

You get an error for the call of System.Number.ParseInt32(...).

The error occurs in method:
"public override object ConvertDbValue(object value, Type type)"
This line produces the error: 
"var intVal = int.Parse(value.ToString());" 

value is bool, which means value.ToString() results either as the string "true" 
or "false". When trying to int.Parse a string like "true" or "false" the result 
is a parse error. It would be better to use Convert.ToInt32(...) instead.

Original issue reported on code.google.com by Heiko.To...@gmail.com on 31 Aug 2010 at 11:02

GoogleCodeExporter commented 8 years ago
btw. the email address "demis@servicestack.net" seems to be no longer valid, it 
has been rejected by the server.

Original comment by Heiko.To...@gmail.com on 31 Aug 2010 at 11:06

GoogleCodeExporter commented 8 years ago
Hi,

Well the root cause is that I'm treating bool's as ints in SqlServer. In my 
experience I've found this to be the least problematic, most portable approach 
to dealing with bool values in SqlServer.

I've modified the code base to use Convert.ToInt32() as you suggested but I'm 
not very hopeful that this will actually fix the issue. I'd recommend you let 
OrmLite create the tables for you or just use int's since I believe you may run 
into future issues ahead.

Anyway I've attached the new build with your fix, let me know if it works for 
you.

P.S. Yeah I don't know why "demis@servicestack.net" no longer works its a 
google app engine account and I could still log in. My real email is 
"demis.bellot at gmail.com", where did you find "demis@servicestack.net" as I 
should update it?

Cheers,
- Demis

Original comment by demis.be...@gmail.com on 31 Aug 2010 at 12:53

Attachments: