the biggest difference is sets have exactly 1 instance of an object in
their collection. a collection can have multiple instances.
There are also set operations which are part of the ISet<> interface
which can be useful. here is an example of exactly 1 instance:
var entity = new Entity(1);
var set = new HashedSet<Entity>();
set.Add(entity);
set.Add(entity);
Assert.That(set.Count, Is.EqualTo(1));
var collection = new List<Entity>();
collection.Add(entity);
collection.Add(entity);
Assert.That(collection.Count, Is.EqualTo(2));
I have also found that Lists and Sets behave differently when they are
mapped to M:N relationships.
On Dec 23, 6:44 am, José F. Romaniello <
jfromanie...@gmail.com> wrote:
> The only way to use SETs in nhibernate is with Sets from Iesi.Collections.
> Having say that your field or property type could be ICollection but the
> instance in transients objetcs must be set, this is an example:
>
> public class Invoice
> {
> private ISet<InvoiceLIne> lines = new HashedSet<InvoiceLine>();
>
> public ICollection<InvoiceLine> Lines {get{return lines;}}
>
> }
>
> this is ok too:
>
> public class Invoice
> {
> private ICollection<InvoiceLine> lines = new HashedSet<InvoiceLine>();
>
> public ICollection<InvoiceLine> Lines {get{return lines;}}
>
> }
>
> but you miss sets operations.
>
> 2010/12/23 Max André Bündchen <
maxbundc...@gmail.com>
>
> > I'm reading the NHibernate 3.0 Cookbook and a question appeared when I
> > played with NHibernate. As the System.Collections.Generic.ISet is not
> > supported in <set> mappings, I can use the
> > Iesi.Collections.Generic.ISet or the
> > System.Collections.Generic.ICollection.
>
> > What's the drawback of use native ICollection instead of ISet? I found
> > a few topics about it but not a clear answer.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to
nhu...@googlegroups.com.
> > To unsubscribe from this group, send email to
> >
nhusers+u...@googlegroups.com<
nhusers%2Bunsu...@googlegroups.com>
> > .