什么是Microsoft.P​​ractices.EnterpriseLibrary.Data [英] what is Microsoft.Practices.EnterpriseLibrary.Data

查看:321
本文介绍了什么是Microsoft.P​​ractices.EnterpriseLibrary.Data的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是 Microsoft.P​​ractices.EnterpriseLibrary.Data ,为什么我们使用这个DLL。
什么是这个dll的好处。

I want to know what is Microsoft.Practices.EnterpriseLibrary.Data and why we use this dll. what are the benefits of this dll.

我要创建3层架构的一个项目什么是SQL查询的最佳方式。

I want to create a project on 3-tier architecture what is the best way for sql queries.

天气我用这个DLL或去简单的SqlCommand和DataAdapter。
目前,我以这种方式工作:
在DAL文件我的code是:

weather i use this dll or go for simple sqlcommand and dataadapter. currently i am working in this way: My Code in DAL File is:

public void Insert(long id)
{
    connection.Open();
    SqlCommand dCmd = new SqlCommand("test_procedure", connection);
    dCmd.CommandType = CommandType.StoredProcedure;
    try
    {
        dCmd.Parameters.AddWithValue("@id", id);           
        dCmd.ExecuteNonQuery();
    }
    catch
    {
        throw;
    }
    finally
    {
        dCmd.Dispose();
        connection.Close();
        connection.Dispose();
    }
}

我困惑的天气我在正确的方式工作或我应该使用 Microsoft.P​​ractices.EnterpriseLibrary.Data 然后我创建 DatabaseFactory

推荐答案

在Microsoft.P​​ractices.EnterpriseLibrary.Data库的主要优点是,它使得它更容易产生数据库无关code。开发人员互动主要是与更通用的数据库VS SqlConnection和VS的DbCommand对象的SqlCommand,理论上切换基础数据库,从MSSQL Oracle的机构变得比较容易。虽然在我的开发经验,我从来没有看到发生的。

The main advantage of the Microsoft.Practices.EnterpriseLibrary.Data library is that it makes it easier to produce database-agnostic code. The developer interacts mainly with more generic Database vs SqlConnection and DbCommand vs SqlCommand objects, in theory the mechanism of switching the underlying database, from MSSQL to Oracle becomes somewhat easier. Even though in my development experience I've never seen that occur.

Microsoft.P​​ractices.EnterpriseLibrary.Data还指示开发人员使用的DbParameter查询参数,从而降低SQL注入攻击的风险。

Microsoft.Practices.EnterpriseLibrary.Data also directs the developer to use DbParameter for query parameters, which reduces the risk of SQL injection attacks.

的Microsoft.P​​ractices.EnterpriseLibrary.Data是核心ADO净构建体更高的抽象和使显影剂来完成同样的任务在code的最小量。

The Microsoft.Practices.EnterpriseLibrary.Data is a higher abstract of the core ADO .Net constructs and enables the developer to complete the same tasks in a minimal amount of code.

如果我建议使用ADO的.Net继续你的学习数据访问策略,你越了解的基础知识比较有用的Microsoft.P​​ractices.EnterpriseLibrary.Data或实体框架或NHibernate的是使用,因为你懂基本面,因为技术已经内置在ADO的.Net之上。

If your learning Data access strategies I suggest continuing with ADO .Net the more you understand the basics the more useful Microsoft.Practices.EnterpriseLibrary.Data or Entity Framework or NHibernate is to use because you understand the fundamentals since the technologies are built on top of ADO .Net.

这篇关于什么是Microsoft.P​​ractices.EnterpriseLibrary.Data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆