I figured this out. You can just group the whole association, so
instead of

.Add(Projections.GroupProperty("sf.SearchFilterID"), "SearchFilterID")
_
.Add(Projections.GroupProperty("sf.SearchFilterName"),
"SearchFilterName") _
.Add(Projections.GroupProperty("sf.SearchGroup"), "SearchGroup") _
.Add(Projections.GroupProperty("sf.DisplayOrder"), "DisplayOrder") _

You can just use

.Add(Projections.GroupProperty("SearchFilter"), "SearchFilter")

On Jun 30, 11:25 am, JamesSpibey <[email protected]> wrote:
> Hi,
>
> I have a class which is as follows
>
> Class SearchFilter
>   Public Property SearchFilterID As Integer
>   Public Property SearchFilterName As String
>   ...
> End Class
>
> Public Class SearchFilterCount
>   Public Property SearchFilterCountID As Integer
>   Public Property SearchFilter As SearchFilter
>   Public Property ItemCount As Integer
> End Class
>
> I am trying to return a SearchFilterCount object from a ICriteria
> query as follows (removed some details for clarity)
>
>     qry.CreateAlias("SearchFilter", "sf",
> SqlCommand.JoinType.InnerJoin) _
>                .SetProjection(Projections.ProjectionList() _
>                               .Add(Projections.GroupProperty
> ("sf.SearchFilterID"), "SearchFilterID") _
>                               .Add(Projections.GroupProperty
> ("sf.SearchFilterName"), "SearchFilterName") _
>                               .Add(Projections.GroupProperty
> ("sf.SearchGroup"), "SearchGroup") _
>                               .Add(Projections.GroupProperty
> ("sf.DisplayOrder"), "DisplayOrder") _
>                               .Add(Projections.CountDistinct
> ("Contract.ContractID"), "ItemCount")) _
>                               .SetResultTransformer
> (Transformers.AliasToBean(GetType(SearchFilterCount)))
>
> The sql is produced correctly but the AliasToBean method cannot map
> the SearchFilterCount object. I get the following error
>
> "Could not find a setter for property 'SearchFilterID' in class
> 'SearchFilterCount'"
>
> I've tried prefixing the projected values with the name of the nested
> class, i.e.
>
> .Add(Projections.GroupProperty("sf.SearchFilterID"),
> "SearchFilter.SearchFilterID") _
>
> but that didn't work either.
>
> Is there a way to do this?
>
> Thanks
>
> James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to