-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Using generic collections
PostPosted: Sun Jan 08, 2006 12:17 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
Are there any major disadvantages with using a wrapper for the collections to get a nice interface?
This is what I mean:

Code:
class Company {
IList departments;

public IList<Department> Departments
{
   get
  {
     return new Wrapper<Department>(departments);
   }
}
}

class Wrapper<T> : IList<T>
{
  private IList list;

  public Wrapper(IList list)
  {
   this.list = list;
  }

public int  IndexOf(T item)
{
    return list.IndexOf(T);
}

// and so on...

}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 08, 2006 1:56 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Official, native support for generics in NHibernate does not exist yet - work has just started. In the mean time, I'm using this: http://www.ayende.com/projects/nhibernate-query-analyzer/generics.aspx Is that what you're looking for?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 3:39 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
Thanks for your answer!
That package seem to provide generic collections, but also do some additional stuff on bidirectional mapping. I'm a little bit reluctant to using it because of that. I want my quick-fix for using generics to be as easy to remove as possible when the generics support become native in NHibernate.

So, are there any problems doing it my way?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 4:09 pm 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
no, if you map with a field strategy.

go for it!

It does seem like a lot of work though, you could also use ayende's solution and rip out the bi-directional stuff.
Or you could look at the cvs, i think that mike is checking in several generic bag related files as we speak. So it will be a matter of days before you have something beta-like to play with.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.