Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a 'Bag' and a 'Set' in nHibernate?

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?

like image 289
Ciel Avatar asked Dec 05 '22 22:12

Ciel


2 Answers

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
like image 63
StuartLC Avatar answered Dec 21 '22 21:12

StuartLC


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

like image 29
Cole W Avatar answered Dec 21 '22 20:12

Cole W