Recommendations for supporting both Oracle and SQL Server in the same ASP.NET app with NHibernate

后端 未结 2 670
逝去的感伤
逝去的感伤 2020-12-29 12:26

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 con

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 13:10

    You can easily use NHibernate to make your application database-agnostic by following some basic practices:

    • 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 or guid) 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 has a great community. You can always ask your questions in http://groups.google.com/group/nhusers besides posting here.

提交回复
热议问题