I have a ContractElement domain object, with a property that relates to a corresponding Team domain object. When I execute the following code:
Code:
DetachedCriteria crit = DetachedCriteria.For<ContractElement>();
crit.SetProjection(Projections.GroupProperty("Team"));
...
crit.GetExecutableCriteria(session).List<ContractElement>();
I get the exception:
Code:
System.ArgumentException: The value "Domain.Team" is not of type "Domain.ContractElement" and cannot be used in this generic collection.
Parameter name: value
at System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object value, Type targetType)
at System.Collections.Generic.List`1.VerifyValueType(Object value)
at System.Collections.Generic.List`1.System.Collections.IList.Add(Object item)
at NHibernate.Util.ArrayHelper.AddAll(IList to, IList from)
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
NHibernate.ADOException: Unable to perform find
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
at NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria)
at NHibernate.Impl.CriteriaImpl.List[T]()
All I want is to group my results so I'll only have one element per team. Is there something I'm missing here that's making this not work?
TIA,
Doug