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

推荐订阅源

T
Tailwind CSS Blog
V
Vulnerabilities – Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
V2EX - 技术
V2EX - 技术
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Fortinet All Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
A
Arctic Wolf
美团技术团队
Cloudbric
Cloudbric
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
S
Security Affairs
T
Tenable Blog
MyScale Blog
MyScale Blog
W
WeLiveSecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
博客园_首页
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
月光博客
月光博客
宝玉的分享
宝玉的分享
博客园 - Franky
PCI Perspectives
PCI Perspectives
H
Hacker News: Front Page
D
Docker
博客园 - 司徒正美
L
LINUX DO - 最新话题
GbyAI
GbyAI
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
InfoQ
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
T
Threatpost
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
AI
AI
有赞技术团队
有赞技术团队
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
O
OpenAI News

博客园 - 无常

用 Zig 写了个 MCP Server,让 AI Agent 直接操控你的 Outlook ABP点滴:API无权访问资源时,返回 PolicyName 信息 使用MSBUILD 构建时出错 error MSB3086: Task could not find "sgen.exe" using the SdkToolsPath PPTPD默认MTU太大引起一些网站上不了的问题 CentOS 6.0 安装配置rails 2.3.11 + redmine 1.2.1 笔记 MVC3中实现验证提示信息多语言支持 MVC3中使用验证适配器修改默认的验证提示信息 nginx 截断日志一个批处理 在没有安装有mvc3的主机上部署asp.net mvc3网站,需要包含的DLL文件 ASP.NET MVC 2 RTM client side validation一个隐秘的坑 Python:使用ctypes库调用外部DLL NHibernate+Oracle 遇到ORA-01461和ORA-01084及解决方法 ASP.NET MVC中实现多个按钮提交的几种方法 - 无常 - 博客园 为cnblogs定做一个代码插入代码的windows live writer插件 MVC 2.0: ConvertEmptyStringToNull 带来烦恼 Code: jsTree ajax 选择行政区域 送出15个Google Wave邀请,需要的赶快 GeekOS:Project1. Loading Executable Files GeekOS:二、Project0 GeekOS: 一、构建基于Ubuntu9.04的实验环境
动刀EFOracleProvider,使其支持char、timestamp(x)等类型
无常 · 2009-04-06 · via 博客园 - 无常

2009-04-06 16:08  无常  阅读(2372)  评论()    收藏  举报

之前在一个使用SqlServer数据库的项目中使用过SubSonic,感觉挺好,没遇到什么问题。

于是在上一个网站毫不犹豫的也选择了Subsonic2.1,可这次很失望。SubSonic2.1 to Oracle11并不像对SqlServer的支持那么好,很多时间,忙于给Subsonic补漏。

这次,想改用ADO.NET EF + EFOracleProvider。

关于EFOracleProvider的使用介绍可以参考一下这里:

1.ADO.NET Entity Framework支持多Provider

2.Using EF Oracle Sample Provider with EDM Designer

可是刚开始就遇到问题,在使用Edmgen.exe生成模型时,提示char和timestamp(x)类型不支持!

image

无奈,要动刀了。

还好,EfOracleProvider的代码不多,不用多久就找到了阵眼。

EfOracleProvider/Resources/EFOracleProviderManifest.xml,在这个文件中声明了Oracle字段和.net数据类型的映射关系。

打开此文件,添加一段:

    <Type Name="char" PrimitiveTypeKind="String">
     <FacetDescriptions>
        <MaxLength Minimum="1" Maximum="4000" DefaultValue="4000" Constant="false" />
        <Unicode DefaultValue="false" Constant="true" />
        <FixedLength DefaultValue="true" Constant="true" />
     </FacetDescriptions>
    </Type>

重新编译,能识别char字段了。

如果数据库中有timsstamp(x)类型的字段,得继续..

在xml文件中再增加类似这样的:

    <Type Name="timestamp(6)" PrimitiveTypeKind="DateTimeOffset">
     <FacetDescriptions>
        <Precision Minimum="0" Maximum="6" DefaultValue="6" Constant="false" />
     </FacetDescriptions>
    </Type>
    <Type Name="timestamp(3)" PrimitiveTypeKind="DateTimeOffset">
     <FacetDescriptions>
        <Precision Minimum="0" Maximum="3" DefaultValue="3" Constant="false" />
     </FacetDescriptions>
    </Type>

如果还有其它长度的timestamp类型,按此法一一添加。

其后打开EFOracleProviderManifest.cs,找到public override TypeUsage GetEdmType(TypeUsage storeType)函数,

在switch (storeTypeName)这行之前添加

if (storeTypeName.StartsWith("timestamp"))
{
    return TypeUsage.CreateDateTimeTypeUsage(PrimitiveType.GetEdmPrimitiveType(
                                         PrimitiveTypeKind.DateTime), null);
}

把所有 timestamp类型都映射到DateTime类。

如果还有其它未知数据类型,也参照此方法添加。

from:wuchang.cnblogs.com