与NHibernate在同一ASP.NET应用程序中同时支持Oracle和SQL Server的建议 [英] Recommendations for supporting both Oracle and SQL Server in the same ASP.NET app with NHibernate
问题描述
我们的客户希望在下一个项目中同时支持SQL Server和Oracle.我们的经验来自.NET/SQL Server平台.我们将雇用一名Oracle开发人员,但我们关心的是DataAccess代码. NHibernate将使DB Engine对我们透明吗?我不这么认为,但我想听听面临类似情况的开发人员的意见.
Our client wants to support both SQL Server and Oracle in the next project. Our experience comes from .NET/SQL Server platform. We will hire an Oracle developer, but our concern is with the DataAccess code. Will NHibernate make the DB Engine transparent for us? I don't think so, but i would like to hear from developers who have faced similar situations.
我知道这个问题有点模糊,因为我没有Oracle经验,所以我不知道我们会发现什么问题.
I know this question is a little vague, because i don't have Oracle experience, so i don't know what issues we will find.
推荐答案
您可以通过以下一些基本操作轻松地使用NHibernate使您的应用程序与数据库无关:
You can easily use NHibernate to make your application database-agnostic by following some basic practices:
- 首先设计您的对象模型.
- 请勿使用任何特定于数据库的代码.您需要具有良好C#经验的人员,而不是Oracle开发人员.不要依赖触发器,存储过程等之类的东西.
- 让NHibernate至少最初生成数据库模式(您可以稍后调整诸如索引之类的东西),它将为每个数据库选择最佳的可用数据类型.
- 使用与数据库无关的POID生成器(
hilo
或guid
),而不是序列或身份. - 尝试避免使用SQL. HQL和Linq在99%的情况下都能正常工作.
- 避免所有目标数据库(例如,Future,MultiCriteria等)不支持的NH功能
- Design your object model first.
- Do not use any database-specific code. You need somebody with good C# experience, not an Oracle developer. Do not rely on stuff like triggers, stored procedures, etc.
- Let NHibernate generate the DB schemas at least initially (you can tweak things like indexes later) It will choose the best available datatypes for each DB.
- Use a DB-agnostic POID generator (
hilo
orguid
) instead of sequences or identity. - Try to avoid using SQL. HQL and Linq work fine in 99% of the cases.
- Avoid NH features that are not supported by all of your target DB (for example, Future, MultiCriteria, etc)
NHibernate有一个很棒的社区.您随时可以在 http://groups.google.com/group/nhusers 中提问.除了在这里发布.
NHibernate has a great community. You can always ask your questions in http://groups.google.com/group/nhusers besides posting here.
这篇关于与NHibernate在同一ASP.NET应用程序中同时支持Oracle和SQL Server的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!