Entity Framework中的实体类型 :

在之前的章节中我们介绍过从已有的数据库中创建EDM,它包含数据库中每个表所对应的实体。在EF 5.0/6.0中,存在POCO 实体和动态代理实体两种。

POCO Entity (Plain Old CLR Object):

POCO类是不依赖任何框架的类型,如同其他正常的一般类型,我们称之为"Plain Old CLR Objects"(这里不知道怎么翻译,普通的CLR对象?古老的CLR对象?大概意思就是没有什么特殊的对象吧)。

POCO 实体(又名非持久化对象)是又EDM创建出来的支持查询,插入,更新,删除行为的实体类型。下面是一个Student 的 POCO 实体

 1 public class Student
 2 {
 3     public Student()
 4     {
 5         this.Courses = new List<Course>();
 6     }
 7     
 8     public int StudentID { get; set; }
 9     public string StudentName { get; set; }
10     public Nullable<int> StandardId { get; set; }
11     
12     public Standard Standard { get; set; }
13     public StudentAddress StudentAddress { get; set; }
14     public IList<Course> Courses { get; set; }
15 }
16         
View Code

相关文章:

  • 2021-09-27
  • 2021-09-27
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-09-27
  • 2021-09-27
猜你喜欢
  • 2021-10-12
  • 2022-01-05
  • 2021-09-27
  • 2022-12-23
相关资源
相似解决方案