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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 七思软件

基于.Net的架构设计之七 基于.Net的架构设计之五 基于.Net架构设计之四 基于.Net架构设计之三 基于.Net架构设计之二 基于.Net的架构设计之一 Microsoft.Visual.Studio.2005.Team.System 面象asp.net2.0的MasterControls控件 aspx页面中标题单点解决方案 求助,web应用程序中的进程线程控制 (The 'url' property had a malformed URL)求助 - 七思软件 Asp.net 2.0功能体验,细节之Web控件(一) 隐藏控件 Asp.net 2.0功能体验,总体设计思想 Asp.net 2.0功能体验,欢迎光临指导 C#中泛型求助 C#2.0中可空类型 迎接.Net2.0 我只是一只碌碌无为的工蚁 : ( 论Web控件开发 - 完美上传下载控件“新”(五)
基于.Net架构设计之六
七思软件 · 2009-11-30 · via 博客园 - 七思软件

二、数据访问层

对于数据访问层,为了方便在不同数据库产品之间的切换,我觉得最好仅是对数据库过程的简单包装,并通过指令配置文件来完成上层包装代码和底层数据库相关代码的分离,在架构中我们可以考虑以下措施来帮助开发人员:

1.编写数据访问对象基类,在基类中完成一些通用过程,如数据库链接对象、指令对象的加载、解析、缓存等等。

2.开发生成模板,自动产生底层存贮过程的包装,建议生成的项目文件如下:

其中*DataAccess.cs文件仅是一个空的类框架,这个文件用来给开发人员手工添加代码,如下:

而*DataAccess.generated.cs中则保存真正的生成代码,

 
最后两个类通过partial关键字关联,编译时就象是一个文件,这样做的好处在于把生成代码和手工代码分离,当由数据库变化引起生成工具重新生成时,不会相互覆盖。

 3.提供开发规范、开发代码供程序员参考,比如说为了便于移植要求程序员在C#代码中不能有任何SQL语句,所有SQL语句都将写在配置文件中,而为了防止SQL注入,必需编写存贮过程等等。