问题描述
假设映射属性的类型是一个Iesi集合,那么是(b)
$ b
HasMany(x => x.MySetProperty)
.AsSet();
和
HasMany(x => x.MySetProperty);
假设您的类型是一个Iesi集合,区别;它自己的 HasMany
调用足够聪明,知道你想要一个Set。 AsSet
是在FNH可能无法按类型确定的情况下将HasMany显式更改为Set的一种方式,例如,如果您要将集合公开为一个 IEnumerable
它会默认为一个Bag,调用 AsSet
会覆盖那个。
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);
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.
这篇关于FluentNHibernate:AsSet()的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!