添加Net4CollectionTypeFactory的原因
.NET4.0已经实现了该功能
http://jahav.com/blog/nhibernate-using-net-4-iset/
NHibernate using .NET 4 ISet
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的原因的更多相关文章
- 配置python+mod_wsgi+apache 时 在浏览器中访问服务器时报错:Invalid HTTP_HOST header: 'XXXXX'. You may need to add u'XXXXX' to ALLOWED_HOSTS,在setting.py中添加‘*”无效的原因
配置python+mod_wsgi+apache 时 在浏览器中访问服务器时报错:Invalid HTTP_HOST header: 'XXXXX'. You may need to add u'XX ...
- CSS3 @font-face的url要添加?#iefix的原因
转至:https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face When using @font-face to declare mu ...
- iOSAPP添加启动页
如果你在开发过程中出现屏幕显示内容比例不正常或者显示不全的问题,你发现不是代码或者约束的问题,那么很可能是启动页没有添加或者添加不全的原因,下面配一张问题图片上下黑屏 添加启动页步骤如下图 (1) ( ...
- 【京东账户】——Mysql/PHP/Ajax爬坑之添加购物车
一.引言 做京东账户项目中的购物车模块,功能之一就是添加购物车.要用到的是Apach环境,Mysql.PHP以及Ajax. 预计效果:用户点击->"加入购物车" 添加成功 ...
- 关于element-ui表格table设置header-cell-class-name样式不起作用的原因分析
在编写表格的时候想给表头添加样式,使用 header-cell-class-name怎么都添加不上样式,检查元素发现连class都没添加上,查了很多资料有人说element之前版本不支持这属性,但我使 ...
- Mysql数据库报错:Cannot add or update a child row: a foreign key constraint fails(添加多对多关系)
#创建班级表 class Classes(models.Model): title = models.CharField(max_length=32) n=models.ManyToManyField ...
- c#实现任务栏添加控制按钮
Windows7Taskbar的使用 你需要引入3个文件VistaBridgeLibrary.dll.Windows7.DesktopIntegration.dll.Windows7.DesktopI ...
- VS 项目没有“添加引用”选项
出问题的环境:vs2017,unity2017unity创建工程后,vs打开项目后,无法添加引用dll,没有“添加引用”项原因: 需要把目标框架改为.
- 在IDE中添加widfly依赖
动机:在IDE中添加widfly依赖 原由:widfly实现了servlet接口,有我们对外交互时所需求的jar包 步骤: 第一步: 找到module依赖的地方 第二步:点击左侧的添加按钮,点击Lib ...
随机推荐
- EJB的魅惑来源
有人发帖子问学习EJB有个屁用啊?看完下面一个简单的介绍,也许你对EJB很感兴趣,它的优点极具魅惑力. 一.EJB是基于组件的开发. 利用Enterprise JavaBean,你就能像搭积木一样 ...
- Vue.nextTick和Vue.$nextTick
`Vue.nextTick(callback)`,当数据发生变化,更新后执行回调. `Vue.$nextTick(callback)`,当dom发生变化,更新后执行的回调. 参考原文:http://w ...
- 4 云计算系列之Openstack简介与keystone安装
preface KVM 是openstack虚拟化的基础, 再介绍了kvm虚拟化技术之后,我们介绍下openstack和如何搭建. Openstack组件 openstack架构图如下所示 那么我们就 ...
- 自动换行后缩进怎么做(CSS)?(可用于 Li y 元素的排版)
<style type="text/css">li{ width:100px; border:1px solid #ccc; padding-left:25px; te ...
- redis 的 HyperLogLog
Redis 在 2.8.9 版本添加了 HyperLogLog 结构. Redis HyperLogLog 是用来做基数统计的算法 HyperLogLog 的优点是,在输入元素的数量或者体积非常非常大 ...
- 关于High-Contrast的资料
SystemParameters.HighContrast Propertyhttp://msdn.microsoft.com/en-us/library/system.windows.systemp ...
- Blender 编辑模式
1.如何进入编辑模式 可直接通过“Tab”快捷键进入编辑模式,或者选择界面底部的下拉列表: 如果想退出编辑模式,可再按下“Tab”键退出. 2.编辑选择 进入编辑状态后,我们可以通过鼠标右键来选择某个 ...
- Python爬虫-豆瓣电影 Top 250
爬取的网页地址为:https://movie.douban.com/top250 打开网页后,可观察到:TOP250的电影被分成了10个页面来展示,每个页面有25个电影. 那么要爬取所有电影的信息,就 ...
- re.match re.search re.findall区别
re正则表达式里面,常用的三种方法的区别. re.macth和search匹配得到的是match对象,findall得到的是一个列表. match从字符串开头开始匹配,search返回与正则表达式匹配 ...
- AngularJS------使用VSCode创建的Angular项目部署IIS
转载: http://www.cnblogs.com/kingkangstudy/p/7699710.html 1.进入项目src,执行命令行:ng build 2.步骤1后会生成dist文件 3.打 ...