惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
C
Check Point Blog
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
U
Unit 42
WordPress大学
WordPress大学
B
Blog
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
D
DataBreaches.Net
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家

博客园 - 神话

【源码】非常有用的Vml图像画板(收藏) 为Html 的Select 加一个提示语和输入方法(转载) asp.net三色交替的下拉列表框(转载) 常用正则表达式(收藏) ListBox控件上移、下移操作(Ajax) 客户端实现PadLeft 获取某行的字段ID值(GridView模板列) 日历控件收藏 我的博客地图脚本代码 实时统计输入字符数 我的博客地图特效 生成html页面 初次使用ZedGraph 梅花雪日历控件(网络收藏) 树型菜单<仿QQ型菜单>(网络收藏) 面向对象分析(网络收藏) 常用正则表达式(收集)及使用方法 三层架构(非原创) 网页常用代码小技巧五(网络收藏)
C#的float型,竟然与SQL中float型不对应(转载)
神话 · 2007-09-05 · via 博客园 - 神话

使用NBearMapping做测试,才发现SQL中的float不能被自动Map到实体类型为float字段中。
搜索了一下,才发现SQL中的float对应到C#的double,我晕了。

/// <summary>
        
/// 数据库中与C#中的数据类型对照
        
/// </summary>
        
/// <param name="type"></param>
        
/// <returns></returns>

        private string ChangeToCSharpType(string type)
        
{
            
string reval = string.Empty;
            
switch (type.ToLower())
            
{
                
case "int":
                    reval 
= "Int32";
                    
break;
                
case "text":
                    reval 
= "String";
                    
break;
                
case "bigint":
                    reval 
= "Int64";
                    
break;
                
case "binary":
                    reval 
= "System.Byte[]";
                    
break;
                
case "bit":
                    reval 
= "Boolean";
                    
break;
                
case "char":
                    reval 
= "String";
                    
break;
                
case "datetime":
                    reval 
= "System.DateTime";
                    
break;
                
case "decimal":
                    reval 
= "System.Decimal";
                    
break;
                
case "float":
                    reval 
= "System.Double";
                    
break;
                
case "image":
                    reval 
= "System.Byte[]";
                    
break;
                
case "money":
                    reval 
= "System.Decimal";
                    
break;
                
case "nchar":
                    reval 
= "String";
                    
break;
                
case "ntext":
                    reval 
= "String";
                    
break;
                
case "numeric":
                    reval 
= "System.Decimal";
                    
break;
                
case "nvarchar":
                    reval 
= "String";
                    
break;
                
case "real":
                    reval 
= "System.Single";
                    
break;
                
case "smalldatetime":
                    reval 
= "System.DateTime";
                    
break;
                
case "smallint":
                    reval 
= "Int16";
                    
break;
                
case "smallmoney":
                    reval 
= "System.Decimal";
                    
break;
                
case "timestamp":
                    reval 
= "System.DateTime";
                    
break;
                
case "tinyint":
                    reval 
= "System.Byte";
                    
break;
                
case "uniqueidentifier":
                    reval 
= "System.Guid";
                    
break;
                
case "varbinary":
                    reval 
= "System.Byte[]";
                    
break;
                
case "varchar":
                    reval 
= "String";
                    
break;
                
case "Variant":
                    reval 
= "Object";
                    
break;
                
default:
                    reval 
= "String";
                    
break;
            }

            
return reval;
        }