NHibernateRepository Upgraded for NHibernate 1.2 RC1

Now that NHibernate 1.2 is finally out of Beta stage and into official Release Candidate mode, I felt it was appropriate to upgrade NHibernateRepository to use it. Not much has changed and there isn't any new functionality, but I wrote some tests for it and of course updated its references to NHibernate 1.2 RC1.

You can get the latest NHibernateRepository here.
Print | posted on Friday, April 06, 2007 6:46 PM

Feedback

# re: NHibernateRepository Upgraded for NHibernate 1.2 RC1

Gravatar left by andrey at 4/9/2007 2:35 AM
Simple question here, why in Repository you not used System.Collections.Generic.List<T>?

You use:
public static Collection<T> Find<T>(string hql)
{
using (Repository rep = new Repository())
{
//IList list = rep.Session.Find(hql); // Deprecated with NHibernate 1.2
IList list = rep.Session.CreateQuery(hql).List();
return ToGenericCollection<T>(list);
}
}

private static Collection<T> ToGenericCollection<T>(IList list)
{
Collection<T> coll = new Collection<T>();

if (list != null && list.Count > 0)
{
foreach (T t in list)
{
coll.Add(t);
}
}

return coll;
}

Why not,

public static List<T> Find<T>(string hql)
{
using (Repository rep = new Repository())
{
//IList list = rep.Session.Find(hql); // Deprecated with NHibernate 1.2
IList<T> list = rep.Session.CreateQuery(hql).List<T>();
return list;
}
}
?
Comments have been closed on this topic.