实体框架VS Ado.net [英] Entity Framework VS Ado.net

查看:192
本文介绍了实体框架VS Ado.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是ADO.net和实体框架?

What is the basic difference between ADO.net and Entity Framework?

为什么要使用实体数据模型,而不是命令和数据集?

Why should we use Entity Data Model instead of Commands and Datasets?

推荐答案

ADO.NET实体是一个ORM(对象关系映射)创造了ADO.NET组件更高的抽象对象模型。因此,而不是进入数据集,数据表,命令和连接对象如图所示跌破code,你的工作在更高级别的域对象,如客户,供应商等。

ADO.NET entity is an ORM (object relational mapping) which creates a higher abstract object model over ADO.NET components. So rather than getting into dataset, datatables, command, and connection objects as shown in the below code, you work on higher level domain objects like customers, suppliers, etc.

DataTable table = adoDs.Tables[0];
for (int j = 0; j < table.Rows.Count; j++)
{
    DataRow row = table.Rows[j];

    // Get the values of the fields
    string CustomerName =
        (string)row["Customername"];
    string CustomerCode =
        (string)row["CustomerCode"];
}

下面是$ C $下实体框架中,我们正在努力,如客户更高层次的域对象,而不是与基础级别ADO.NET组件(如数据集,DataReader的,命令,连接对象,等等)。

Below is the code for Entity Framework in which we are working on higher level domain objects like customer rather than with base level ADO.NET components (like dataset, datareader, command, connection objects, etc.).

foreach (Customer objCust in obj.Customers)
{}

主要和EF的唯一好处是它自动生成code的模型(中间层),数据访问层和映射code,这样可以减少大量的开发时间。

The main and the only benefit of EF is it auto-generates code for the Model (middle layer), Data Access Layer, and mapping code, thus reducing a lot of development time.

这里

这篇关于实体框架VS Ado.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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