.NET4.0已经实现了该功能

http://jahav.com/blog/nhibernate-using-net-4-iset/

NHibernate using .NET 4 ISet

0 Comments

NHibernate 4.0 (released in 2014-08-17) has brought us support for .NET 4 ISet<> collections, thus freeing us from the tyranny of the Iesi package. But long before that, there was a way to use .NET 4 ISet in you NHibernate 3 projects:

NHibernate.SetForNet4

SetForNet4 is a NuGet package you can install into your application. Once you install it, there will be a new file with a implementation of a ICollectionTypeFactory in your project that will support System.Collections.Generic.ISet<> instead of Iesi.Collections.Generic.ISet<>. Other than that, it is basically a copy of the original DefaultCollectionTypeFactory.

All you need to do after installation is to set the configuration property “collectiontype.factory_class” to the assembly qualified name of the created factory, make sure the dll with the created collection factory can be loaded (if you have it in separate project) and all will be peachy.

I had slight trouble with configuration, I have configuration spread over the XML and the code and the comment at the top said to add line to my configuration:

//add to your configuration: //configuration.Properties[Environment.CollectionTypeFactoryClass] //        = typeof(Net4CollectionTypeFactory).AssemblyQualifiedName

Since it was integral part of the configuration (not the db dialect or something), I put it to the code

var configuration = new Configuration().Configure(); configuration.Properties[Environment.CollectionTypeFactoryClass]      = typeof(Net4CollectionTypeFactory).AssemblyQualifiedName; 

… and it didn’t work. I had to set the factory before I made configured from XML.

var configuration = new Configuration()     .SetProperty(Environment.CollectionTypeFactoryClass, typeof(Net4CollectionTypeFactory).AssemblyQualifiedName)     .Configure()

I am not exactly sure why, but I think it is because I also have assemblies with *hbm.xml mapping files specified in the XML using <mapping assembly="EntityAssembly" /> tags.

The configuration code have set the collection factory of the bytecode provider before the mapped assemblies were processed.

Downside

It should be noted that using SetForNet4 package, you can’t use both, the Iesi and the .NET4 collections at the same time, thus you need to replace the Iesi in the whole application. Also, we have NH 4.0 now, so doing this is kind of pointless, but I did it before 4.0 and I don’t have time to upgrade to 4.0 and check that my app still works as advertised.

添加Net4CollectionTypeFactory的原因相关推荐

  1. 中国地质大学英语语音学习笔记(四):英语连读——弱读、冠词连读方法(包括元音字母前添加an的原因)和词间辅音加元音的连读方法

    前言   本笔记整理于中国地质大学(武汉)的一门英语发音课程:英语语音,的第九,十单元的文档资料.包括冠词连读(不定冠词连读,定冠词连读,元音字母前用an的原因),弱读和辅音加元音连读的发音技巧.整理 ...

  2. linux添加失败的原因,linux下execvp失败设置errno=7的原因是什么?

    看下面的代码 int main(int c,char** v) { v[c-1] = NULL; execvp("ls",v); perror("execvp" ...

  3. NotePad++不能添加HexEdit的原因

    NotePad++是64位,HexEdit是32位,需要把NotePad++还成32位的

  4. (转)AS3函数动态添加实例属性

    var shot:Function=function():void{         shot['times']++;         trace("shot():times:"+ ...

  5. 网站添加自己公司的地图(使用的百度地图)时只显示一个空白框

    最近维护公司网站时在添加地图出问题了,按照http://api.map.baidu.com/lbsapi/creatmap/网址上制作后复制代码,然后添加到我想弄的位置后显示不出来,只显示了一个空白的 ...

  6. 如果添加1条数据会等待10秒,你愿意等吗

    首先说明,这个问题出于自己写的一个小demo,很简单的数据添加操作,起初就是添加一条数据,成功之后刷新页面.后面觉得,刷新页面体验不好,就改成成功之后异步加载数据了,界面体验好了一些. 但是突然的就在 ...

  7. 给mongoose find()/findOne()查询的结果添加额外的属性

    在学习 mongoose 的时候,碰到一个需要注意的地方. 给查询结果添加额外的属性时,不能直接在这个结果对象上添加属性.原因和解决方案往下看. 假设 User 集合有一个 name 字段: cons ...

  8. 如何为Matlab添加自己喜欢的字体

    笔者选择添加字体的原因 Matlab初始字体比较丑,且其他字体并不能满足笔者对字体的要求.因此笔者选择安装自己喜欢的字体. 方法一:将字体直接添加至Matlab指定的文件夹中 此方法操作步骤如下: 笔 ...

  9. Oracle报错ORA-19400 ORA-24279产生原因和MOS官方解决办法

    原文链接:http://www.oracleplus.net/arch/1209.html ORA-19500设备的块大小的字符串是无效的 原因:通过连续的I / O OSD返回设备的块大小是无效的. ...

最新文章

  1. 浅谈C/C++中的static和extern关键字
  2. 基于springboot实现快递代取管理系统
  3. oracle 优化逻辑读过高,详述逻辑读与arraysize的关系
  4. 【攻防世界010】re1-100
  5. ACM入门之【快速幂】
  6. 深入理解Java类加载器:Java类加载原理解析
  7. 蓝桥杯算法训练超全习题题解——ALGO-3.K好数**
  8. Git LFS 初探
  9. 【AI视野·今日CV 计算机视觉论文速览 第169期】Fri, 22 Nov 2019
  10. 2008年世界各国最新GDP排名
  11. 高仿绚丽彩虹悬浮音乐播放器html5源码
  12. 华米科技“中美两开花”:美股主体将更名为ZEPP,业绩已腰斩
  13. 清除www.2345.com修改首页的方法
  14. 测试点 - 发朋友圈
  15. 阿里云OSS 图片处理
  16. android手机——刷机(卡刷、线刷)
  17. 如何确定自己不是高智商?蒙提霍尔三扇门问题
  18. url 转码 (含中文)%3A转换成“:”,%2F转换成“/”
  19. jQuery设置内容和属性
  20. 六十星系之43紫微天相坐辰戌

热门文章

  1. 最经典的计算机网络新书推荐--计算机网络(第5版)Tanenbaum著中文版上市
  2. 什么是A记录、MX记录、CNAME记录
  3. Gridview][UpdateCommand的写法要点]
  4. 使用Repeater的Template
  5. Linux软连接和硬链接
  6. Redis源码解析——有序整数集
  7. C和C++安全编码笔记:整数安全
  8. 深度学习中的优化简介
  9. 【GLib】GLib学习笔记(二):源码编译
  10. 【Qt】Qt样式表总结(二):冲突和命名空间