entity-framework – 带有实体框架的参数化POCO构造函数

前端之家收集整理的这篇文章主要介绍了entity-framework – 带有实体框架的参数化POCO构造函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
根据 Initial POCO Design 1-Pager

Persistence Ignorance refers to being
able to allow the developer to write
and test domain objects in a way that
is entirely independent of fundamental
requirements and assumptions that may
be made by the infrastructure service
(in this case,the Entity Framework).
Such requirements / assumptions may
often include:

  • The need to implement a specific interface (for e.g.,IPOCO)
  • Inheritance from a base class
  • Providing specific constructors
  • Object Instantiation/Construction requirements – use a specific factory
    for instance**
  • The need for Metadata or mapping class or property Attributes
  • The need to use specific relationship mechanisms

This amounts to being able to use
Plain Old CLR Objects (POCO) so that a
developer can author their domain
objects free of all assumptions and
requirements imposed by the framework.
Using this approach,once the domain
objects are ready to their
satisfaction,the developer can use
these classes with the Entity
Framework in order for relational
database access and persistence.

截至目前(CTP5),有没有办法使用参数化构造函数重建poco?如果没有,很难看出实体框架如何被称为提供持久性无知.

解决方法

您可以拥有任意数量的参数化构造函数,只要框架可以访问无参数的构造函数,如果您没有构造函数,则默认情况下可用,或者除了您创建的参数化构件之外还提供一个参数化构造函数. .

猜你在找的HTML相关文章