什么是NHibernate中的Tuplizer [英] What is Tuplizer in NHibernate

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

问题描述

我在NHibernate中看到一篇提到Tuplizer的帖子,有人能为Tuplizer提供一个很好的定义或参考吗?

I came across a post that mentioned Tuplizer in NHibernate, can anybody provide a good definition or reference for Tuplizer?

推荐答案

来自

tuplizer为以下内容定义合同 知道如何管理的东西 一件作品的特殊表现 的数据,给定表示的 EntityMode(实体模式 本质上定义了哪个 表示形式.)

A tuplizer defines the contract for things which know how to manage a particular representation of a piece of data, given that representation's EntityMode (the entity-mode essentially defining which representation).

如果认为给定的数据 作为数据结构,然后 翻板机是知道的东西 到:

If that given piece of data is thought of as a data structure, then a tuplizer is the thing which knows how to:

  • 创建这样的数据结构 适当地
  • 从中提取值 并将值注入此类数据 结构
  • create such a data structure appropriately
  • extract values from and inject values into such a data structure

例如,给定的数据 可以表示为POCO类. 在这里,它是代表 实体模式为POCO.好一个tuplizer POCO实体模式会知道 到:

For example, a given piece of data might be represented as a POCO class. Here, it's representation and entity-mode is POCO. Well a tuplizer for POCO entity-modes would know how to:

  • 通过创建数据结构 调用POCO的构造函数
  • 通过以下方式提取和注入值 吸气剂/设定者,或按直接领域 访问等
  • create the data structure by calling the POCO's constructor
  • extract and inject values through getters/setter, or by direct field access, etc

同一条数据 也可能表示为DOM 结构,使用tuplizer 与XML实体模式相关联, 这将生成 XmlElement作为数据结构和 知道如何以下列方式访问值 嵌套的XmlElements或as XmlAttributes.

That same piece of data might also be represented as a DOM structure, using the tuplizer associated with the XML entity-mode, which would generate instances of XmlElement as the data structure and know how to access the values as either nested XmlElements or as XmlAttributes.

法比奥·毛洛(Fabio Maulo):

tuplizer定义如何将Property-Value转换为其持久表示形式,反之亦然,将Column-Value转换为其内存中表示形式,而EntityMode定义如何使用哪个tuplizer.

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.

使用自定义修整器可以做一些事情:

Some things you can do with custom tuplizers:

  • Remote lazy loading (the article uses Java Hibernate but the general concepts apply to NHibernate as well)
  • Seamlessly mapping/persisting interfaces instead of POCOs
  • Mapping/persisting F# records (from the FunctionalNHibernate project)

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

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