FluentNHibernate: What is the effect of AsSet()?

∥☆過路亽.° 提交于 2019-12-21 12:15:39

问题


In Fluent Nhibernate what is the effect of specifying AsSet() on a HasMany or HasManyToMany relationship?

Assuming the type of the mapped property is an Iesi Set, is there any difference between:

HasMany(x => x.MySetProperty)
   .AsSet();

and

HasMany(x => x.MySetProperty);

回答1:


Assuming your type is an Iesi Set, then there's no difference; the HasMany call on it's own is smart enough to figure out that you want a Set. The AsSet is a way to explicitly change your HasMany to a Set in situations where FNH might not be able to determine it by type, for example if you're exposing your collection as an IEnumerable it would default to a Bag and calling AsSet would override that.



来源:https://stackoverflow.com/questions/2054076/fluentnhibernate-what-is-the-effect-of-asset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!