Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FluentNHibernate: What is the effect of 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);
like image 233
cbp Avatar asked Jan 13 '10 02:01

cbp


1 Answers

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.

like image 147
James Gregory Avatar answered Sep 21 '22 21:09

James Gregory