gpt4 book ai didi

nhibernate - 什么是 NHibernate 中的 Tuplizer

转载 作者:行者123 更新时间:2023-12-04 12:02:16 26 4
gpt4 key购买 nike

我在 NHibernate 中看到了一个提到 Tuplizer 的帖子,有人可以为 Tuplizer 提供一个好的定义或引用吗?

最佳答案

来自 ITuplizer's source code :

A tuplizer defines the contract forthings which know how to manage aparticular representation of a pieceof data, given that representation'sEntityMode (the entity-modeessentially defining whichrepresentation).

If that given piece of data is thoughtof as a data structure, then atuplizer is the thing which knows howto:

  • create such a data structureappropriately
  • extract values fromand inject values into such a datastructure

For example, a given piece of datamight be represented as a POCO class.Here, it's representation andentity-mode is POCO. Well a tuplizerfor POCO entity-modes would know howto:

  • create the data structure bycalling the POCO's constructor
  • extract and inject values throughgetters/setter, or by direct fieldaccess, etc

That same piece of datamight also be represented as a DOMstructure, using the tuplizerassociated with the XML entity-mode,which would generate instances ofXmlElement as the data structure andknow how to access the values aseither nested XmlElements or asXmlAttributes.


words of Fabio Maulo :

The tuplizer defines how to transform a Property-Value to its persistent representation, and viceversa a Column-Value to its in-memory representation, and the EntityMode defines which tuplizer is in use.


您可以使用自定义 tuplizer 做一些事情:
  • Remote lazy loading (本文使用 Java Hibernate,但一般概念也适用于 NHibernate)
  • Seamlessly mapping/persisting interfaces instead of POCOs
  • Mapping/persisting F# records (来自 FunctionalNHibernate project)
  • 关于nhibernate - 什么是 NHibernate 中的 Tuplizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/391332/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com