Welcome 微信登录

首页 / 网页编程 / ASP.NET / Entity Framework学习初级篇6--EntityClient

Entity Framework学习初级篇6--EntityClient2010-02-05 博客园 ♂风车车.NetSystem.Data.EntityClient 命名空间是实体框架的.NET Framework数据提供程序。EntityClient 提供程序使用存储特定的ADO.NET数据提供程序类和映射元数据与实体数据模型进行交互。EntityClient首先将对概念性实体执行的操作转换为对物理数据源执行的操作。然后再将物理数据源返回的结果集转换为概念性实体。

EntityClient下的类有以下几个:

l EntityConnection

l EntityCommand

l EntityConnectionStringBuilder

l EntityParameter

l EntityDataReader

l EntityParameterCollection

l EntityProviderFactory

l EntityTransaction

从类的名字上看,我们就知道它们的作用是什么了。在此,就不再一一解释了。直接通过实例代码来学习它们。

l EntityConnection:

实例代码1:

string con = "name = NorthwindEntities";

using (EntityConnection econn = new EntityConnection(con))

{

string esql = "Select VALUE c from NorthwindEntities.Customers as c where c.CustomerID="ALFKI"";

econn.Open();

EntityCommand ecmd = new EntityCommand(esql , econn);

EntityDataReader ereader = ecmd.ExecuteReader(CommandBehavior.SequentialAccess);

if (ereader.Read())

{

Console.WriteLine(ereader["CustomerID"]);

}

Console.WriteLine(ecmd.ToTraceString());

}