开发者

NHibernate number format problem - where do I set the culture?

开发者 https://www.devze.com 2022-12-16 14:29 出处:网络
LATER EDIT : It was me :( It was a non-nullable column left unfilled. Sorry to everyone I confused.. I am having issues with an INSERT statement generated by NHibernate because it formats the decimal

LATER EDIT : It was me :( It was a non-nullable column left unfilled. Sorry to everyone I confused..

I am having issues with an INSERT statement generated by NHibernate because it formats the decimal numbers using the regional settings. The generated statement goes something like :

exec sp_executesql N'INSERT INTO [TableName] (
    Column1, 
    Column2, 
    Column3, 
    Column4, 
    Column5, 
    Column6, 
    Column7, 
    Column8, 
    Column9, 
    Column10) 
VALUES (@p0, 
    @p1, 
    @p2, 
    @p3, 
    @p4, 
    @p5, 
    @p6, 
    @p7, 
    @p8, 
    @p9); 

select SCOPE_IDENTITY()',

N'@p0 float,@p1 float,@p2 float,@p3 float,@p4 int,@p5 datetime,@p6 nvarchar(69),@p7 int,@p8 int,@p9 int',
@p0=0,
@p1=0,
@p2=589186,74188329,           -- <-- here is my problem
@p3=320829,21535209997,        -- <-- here is my problem
@p4=6,
@p5='2009-05-10 17:00:00',
@p6=N'Some string value',
@p7=232323开发者_StackOverflow中文版,
@p8=2,
@p9=1

As you can see there is a comma used as a decimal separator which screws up the parameters value list.

I have not found anywhere a way to set the culture used to format the numbers so the statement would get generated in a valid form.

I set the Thread.CurrentCulture and CurrentUICulture to en-us right before the Save method call on the ISession but nothing happened.

What can be done? :(


But this list with formatted numbers is only for display purposes - the values being set as the parameters are set as floating point numbers. This shouldn't cause the INSERT to fail in any way.

Are you just anticipating a problem, or are you actually getting an error? If you are getting an error, what is it?

0

精彩评论

暂无评论...
验证码 换一张
取 消