4

Using Fluent NHibernate, I come across the mapping AsBag() and AsSet() for HasMany and HasManyToMany relationships. I've done some searches, and I'm just not finding anything. Can anyone explain to me what these mean, and what the significance is?

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
Ciel
  • 17,312
  • 21
  • 104
  • 199
  • possible duplicate of [set/bag and list/set in nhibernate](http://stackoverflow.com/questions/1916350/set-bag-and-list-set-in-nhibernate) – Vadim May 02 '11 at 14:16

3 Answers3

9

The post here succinctly explains the differences.

In summary, they are both unordered collections:

  • Set => Item may not occur more than once
  • Bag => Items may occur more than once
StuartLC
  • 104,537
  • 17
  • 209
  • 285
7

Check out this SO article: List vs Set vs Bag in NHibernate

Community
  • 1
  • 1
Cole W
  • 15,123
  • 6
  • 51
  • 85
0

Check out the mathematical concepts Set / Multiset (Bag) and see if they can push you into the right direction.

http://en.wikipedia.org/wiki/Set_(mathematics)

http://en.wikipedia.org/wiki/Multiset

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
m__
  • 1,721
  • 1
  • 17
  • 30