图片 2

EF是啥?【What is Entity Framework?】(EF基础系列2)

此文演示了PHP三层开垦的强盛作用,PEA逍客::DB_DataObject用于专业逻辑,斯马特y用于体现逻辑,这里假令你纯熟了HTML,斯马特y,PEAHighlander::DB_DataObject,Mysql和PHP5.倘令你需求补给知识,下边的稿子解释了一些规律:用PHP
DataObject简化业务逻辑Smarty简单介绍:一个PHP模板引擎PHP可伸缩性:Myth你应当已安装和布置好了Apache,MySQL,和PHP5(可能IIS,MySQL5和PHP卡塔尔国PEACRUISER::DB_DataObjectPEAR::DB_DataObject
是多个客商数据库访谈的架空API.它是叁个依据PEAWrangler::DB的SQL创设器和数量建立模型层.它把数据库表映射到PHP类况且提供像SELECT,INSERT,UPDATE,和DELETE那样的公共SQL函数.那使即便不通晓SQL的开荒者也得以写出好的数据库访谈代码,而且慰勉演示逻辑和事情逻辑有叁个清楚的分离.(DB_OO已经移动到的PEA兰德LAND,现在是DB_DataObject,如果你有老的代码要改良,查看关于从老的db_oo代码更新到DB_DataObjects的申明卡塔尔(قطر‎.相关阅读Upgrading
to PHP 5By Adam TrachtenbergTable of ContentsIndexSample ChapterRead
Online–Safari Search this book on Safari: Only This Book All of
SafariCode Fragments only DataObject performs two tasks. First, it
builds SQL statements based on the object”s variables and the
buildermethods. Second, it acts as a datastore for a table row. There”s
a core class, which you extend for each ofyour tables so that you put
the data logic inside the data classes. There”s also an included
Generator to makeyour configuration files and your base
classes.DataObject
实施四个职务.第生机勃勃,它创设基于对象变量的SQL语句和创设器方法.第二,它当作数据库表的数量存款和储蓄.这里有个主导类,对于每种表世袭它,以令你把数据逻辑归入数据类中.这里还包罗贰个生成器,DataObject
十分的大的简化了数据库访谈代码,它使支付大型的,数据驱动的站点尤其轻便.At
present, 艾伦 Knowles, the lead developer of PEA揽胜极光::DB_DataObject, is
working on a new project called DBDO,a C implementation of the PEAR
package DB_DataObjects, based on libgda. His goal is to create the
nextgeneration of
PEAR::DB_DataObjects.SMARTY斯Matty是二个从web页演示中分离内容的PHP模板引擎.它选拔GPL许可.Large
projects commonly separate the role of the graphic designer from that of
the programmer. However,programming in PHP has the tendency to combine
those two roles in a person and inside the code. This can
bringdifficulties when it comes time to change some part of the page”s
design. If the page mixes content andpresentation, the developer has to
crawl through the program to find the presentation. Smarty helps to
solvethis problem.Combining the TwoThe first thing to do when starting
this project is

    编写ADO.NET访问数据的代码,是沉闷而干燥的,所以微软提供了四个对象关联映射框架(大家称之为EF),通过EF能够自行扶助大家的主次自动生成相关数据库。

Writing and managing
ADO.Net code for data access is a tedious and monotonous job. Microsoft
has provided an O/RM framework called “Entity Framework” to automate
database related activities for your application.

1.按照现已存在的数据库,生成相关类;

EF是三个指标关系映射【ORM】的框架,它有限支撑技士把相关的数据作为特意的小圈子对象,收缩了技师编写大量的走访数据库的代码。开采职员,使用LINQ来查询,检索,操作数据为强类型对象来管理。EF框架提供了变动追踪,身份鉴定识别,懒加载,和询问调换,所以开垦职员能够小心于她们的前后相继中的逻辑代码,实际不是数量访谈根基。

The Microsoft ADO.NET
Entity Framework is an Object/Relational Mapping (ORM) framework that
enables developers to work with relational data as domain-specific
objects, eliminating the need for most of the data access plumbing code
that developers usually need to write. Using the Entity Framework,
developers issue queries using LINQ, then retrieve and manipulate data
as strongly typed objects. The Entity Framework’s ORM implementation
provides services like change tracking, identity resolution, lazy
loading, and query translation so that developers can focus on their
application-specific business logic rather than the data access
fundamentals.

EF发生的背景:

EF的四个应用项景:

Entity framework is an
Object/Relational Mapping (O/RM) framework. It is an enhancement to
ADO.NET that gives developers an automated mechanism for accessing &
storing the data in the database.

Entity framework is
useful in three scenarios. First, if you already have existing database
or you want to design your database ahead of other parts of the
application. Second, you want to focus on your domain classes and then
create the database from your domain classes. Third, you want to design
your database schema on the visual designer and then create the database
and classes.

The following figure
illustrates the above scenarios.

     ORM允许大家把数据库设计和领域类设计分开来,那样保险了程序的可维护性和可扩大性,ORM同样自动帮助大家转移了增加和删除查改(CU奥迪Q3D)操作,所以大家不必手动去写了。

 

     图片 1

ORM框架分类:

  1. ### DataObjects.Net

  2. ### NHibernate

  3. ### OpenAccess

  4. ### SubSonic 

  5. ### 请留意:EF是微软的开源ORM框架,所谓开源就是您能够参预开采,有意思味的能够去这些网址看看:codeplex.

3.在可视化的设计器中,来成立类和数据库;

 

 图片 2

 

As per the above figure,
EF creates data access classes for your existing database, so that you
can use these classes to interact with the database instead of ADO.Net
directly.

EF can also create the
database from your domain classes, thus you can focus on your
domain-driven design.

EF provides you a model
designer where you can design your DB model and then EF creates database
and classes based on your DB model.

 

O/RM蕴涵3个至关心重视要的风华正茂对:

           3.映射音讯(领域对象,怎么着映射到数据库对象【表,视图,存款和储蓄进程】?)

EF的定义:

什么是O/RM?

 

ORM is a tool for storing
data from domain objects to relational database like MS SQL Server, in
an automated way, without much programming. O/RM includes three main
parts: Domain class objects, Relational database objects and Mapping
information on how domain objects map to relational database objects
(tables, views & storedprocedures). ORM allows us to keep our database
design separate from our domain class design. This makes the application
maintainable and extendable. It also automates standard CRUD operation
(Create, Read, Update & Delete) so that the developer doesn’t need to
write it manually.

 

A typical ORM tool
generates classes for the database interaction for your application as
shown below.

 

 

           1.领域类对象

     2.关周密据库对象

Tips:要了然越多的ORM技巧,能够访谈 那么些链接: Object-relational Mapping

Visit wikipedia for more
information on Object-relational
Mapping

There are many ORM
frameworks for .net in the market such as DataObjects.Net, NHibernate,
OpenAccess, SubSonic etc. Entity Framework is an open source ORM
framework from Microsoft.

Please note that Entity
Framework is an open source framework
 by Microsoft. You can contribute
to the Entity Framework project oncodeplex.

2.基于有关领域类,生成数据库;

ORM是一个工具,它能够自动的囤积数据库(举个例子MS SQL Server)中世界对象中的数据,而不必要多多编程。

好了,EF的牵线到此甘休了。前面继续立异,感觉不错的,园友能够点赞,你的扶植是自家前行的重力!

发表评论

电子邮件地址不会被公开。 必填项已用*标注