什么是实体?为什么称为实体? [英] What is an Entity? Why is it called Entity?

查看:748
本文介绍了什么是实体?为什么称为实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与实体打交道(在谈论实体框架时)?据我了解,它几乎是数据存储区(如sql表)的内存表示形式。实体足够聪明,可以跟踪更改并将这些更改应用于数据存储。

What is the deal with Entities (when talking about the Entity Framework)? From what I understand, it is pretty much an in memory representation of a data store like sql tables. Entities are smart enough to track changes and apply those changes to the data store. Is there anything more to it?

预先感谢。

推荐答案

它来自系统工程领域,他们使用实体关系图工具进行设计

It comes from the field of systems engineering where they use the Entity Relationship Diagram tool to design systems.

他们要做的是从布置实体(例如客户,采购订单,采购订单行项目等)开始。每个实体都是概念性的东西。然后,通常为每个实体创建一个实体类,并创建一个数据库表作为后备存储。实体框架允许您执行的操作是假设数据库模型已经很好地表示了您的实体图,并自动生成了实体类来封装它们。

What they do is start by laying out the entities (things like customers, purchase orders, purchase order line items, etc.). Each entity is a conceptual thing. Then you generally create an entity class for each entity, and a database table as your backing store. What the entity framework allows you to do is take a database schema, assuming it's already a good representation of your entity diagram, and automatically generate entity classes to encapsulate those.

实体是系统中真实事物的抽象,通过为每个实体创建一个类,这是构造系统以将每个实体的相关代码放在正确位置的一种好方法。框架的工作方式是创建两个文件:一个映射到数据库字段的自动生成的文件,以及一个可以放置自定义逻辑的自定义文件。这些文件定义为部分类文件,因此在编译时将它们连接在一起以形成一个类,但是它使您的数据访问和业务逻辑保持良好和独立。然后,只要您的数据库架构(实体关系图)发生更改,就可以重新生成该类的自动生成的部分。

Since an entity is an abstraction of the real things in your system, by creating a class for each entity, it's a nice way to architect your system to put the relevant code for each entity in the right place. The way the framework works is that it creates two files: an auto generated file that maps to the fields of the database, and a "custom" file where you can put custom logic. These are defined as partial class files, so they're joined together at compile time to form one class, but it keeps your data access and business logic nice and separate. You can then re-generate the auto-generated partial side of the class any time your database schema (entity relationship diagram) changes.

其他漂亮的功能:


  • 该框架了解实体之间的关系,因此,一旦拥有采购订单实体,就可以自动获取所有采购订单行项目(返回集合的实体的属性)

  • 您可以实现实体继承(例如,员工可以从联系人继承)

  • Linq to实体!

这篇关于什么是实体?为什么称为实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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