所以这是标准: 请尽可能使用ORM(例如NHibernate)(没有LINQ,因为只有它支持SqlServer,但是怎么样实体框架及其支持Oracle和MySql?)如果ORM过于强大,则使用参数化的SQL查询.仅将存储过程用于长时间运行或复杂的操作,这些操作会需要在数据库.哪个使我想到了我即将遇到的主要问题. 我应该使用哪个命名空间来编码我的DAL? 在我看来,选择是在 System.Data.ODBC 和 System.Data.OleDB 之间:需要权衡些什么?一个人优先于另一个人吗?您对前三个标准有何看法?解决方案 System.Data.SQLClient 仅连接到SQL Server 2000和更高版本,但连接到这些数据库时将获得最佳性能. System.Data.OledbClient 连接到SQL 6.5 OLEDBClient使您能够连接到其他数据库,例如ORACLE或Access.但是,使用SQL Server可以使用SQLClient获得更好的性能.注意:为了连接到ORACLE,Microsoft还具有ORACLEClient. System.Data.ODBCClient 使用ODBC驱动程序仅连接到旧数据库.(例如MS Access 97.) 原始来源 I am starting off with a SQLServer database. So it would seem that I should use System.Data.SqlClient namespace. But, there is a chance that we might shut down our SqlServer database and go to MySql or Oracle. For this reason, I am coming up with a set of standards on how our .Net apps will communicate with the database, so as to make it easier to migrate to a different database system in the future if we needed to do so.So here are the standards:Use an ORM if possible (egNHibernate) (No LINQ as it onlysupports SqlServer, but what aboutEntity framework and its support forOracle and MySql?)If ORM is an over-kill, then use parameterized SQL queries.Use stored procedures only for long running or complex actions thatneed to be performed on thedatabase.Which brings me to my main question at hand.Which namespace should I be using to code my DAL?It looks to me that the choice is between System.Data.ODBC and System.Data.OleDB:What are the trade-offs?Is one preferred over the other?What are your thoughts about the first 3 standards? 解决方案 System.Data.SQLClientConnects to SQL Server 2000 and later only, but you will get optimal performance when connecting to those databases.System.Data.OledbClientConnects to SQL 6.5OLEDBClient gives you ability to connect to other database like ORACLE or Access. But for working with SQL Server you will get better performance using SQLClient.Note: For connecting to ORACLE, Microsoft also has ORACLEClient.System.Data.ODBCClientConnects to legacy databases only, using ODBC drivers. (E.g. MS Access 97.)Original source 这篇关于什么时候应该使用Odbc,OleDb,SQLClient?权衡是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 19:24