.net 中 SQL 的 Money 数据类型和十进制类型 [英] Money datatype and decimal type of SQL in .net

查看:48
本文介绍了.net 中 SQL 的 Money 数据类型和十进制类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SQL 表中有持续时间"字段,类型为Bigint",在 SQL 过程中,我们将其除以 3600 时将其转换为十进制,现在,当我们使用此存储过程在 c# 中获取 Datatable 时,我们将获得数据类型为 decimal 的持续时间字段.

I have "duration" Field in SQL table with type "Bigint", inside SQL procedure, we convert it into decimal when we divide it by 3600 , Now when we get Datatable in c# with this Store procedure, we get this duration field with datatype decimal .

现在我们在 SQL 表中有另一个字段Price",类型为Money",该字段被转换为decimal"类型当我们从存储过程获取数据表时,通过 .net 表示SQL 货币类型相当于 .net 十进制类型".

Now we have one another field "Price" in SQL table with type "Money" and this field get converted into "decimal" type by .net when we get datatable from store procedure means "SQL money type is equivalent to .net decimal type " .

现在在代码中,我们有一些基于表字段数据类型的逻辑,所以我们只需要为Money"类型的字段运行这个逻辑,现在我卡在这一点上,我如何区分黑白这些持续时间"和价格"字段是因为在 C# 数据表中它们都是十进制"数据类型.

Now inside code, we have some logic which works on bases of datatype of table fields, So we need to run this logic for only "Money" type fields, Now I got stuck at this point, how can I distinguish b/w these "duration" and "Price" field because in C# datatable they both are in "Decimal" datatype .

现在根据我是否需要将持续时间的十进制转换更改为存储过程中的浮点数或其他内容,请给我建议.

Now according me whether I need to change the conversion of duration by decimal to float in store procedure or something else, Please suggest me .

推荐答案

将查看数据类型的代码更改为查看列名.

Change the code that looks at data types to look at column names instead.

这篇关于.net 中 SQL 的 Money 数据类型和十进制类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆