-->
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.  [ 2 posts ] 
Author Message
 Post subject: Casting error with projection
PostPosted: Fri Feb 12, 2010 5:56 am 
Newbie

Joined: Fri Feb 12, 2010 5:51 am
Posts: 1
Hi,

I'm trying to use NHibernate for the first time. Most of the sample code and sandbox stuff I'm doing to learn the framework seems to work okay, so I assume my mappings are correct, but I can't get projections to work.

Here's the code:
Code:
        Dim crit As ICriteria = session.CreateCriteria(GetType(DataTransferObjects.Product))
        crit.SetProjection(Projections.ProjectionList)
        crit.Add( projections.RowCount()) )
        Dim products As System.Collections.IList = crit.List()


The error gets thrown on crit.Add() and is:
Code:
Unable to cast object of type 'NHibernate.Criterion.RowCountProjection' to type 'NHibernate.Criterion.ICriterion'.


Any suggestions?


Top
 Profile  
 
 Post subject: Re: Casting error with projection
PostPosted: Fri Feb 12, 2010 12:48 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Dim crit As ICriteria = session.CreateCriteria(GetType(DataTransferObjects.Product))
crit.SetProjection(Projections.ProjectionList().Add( projections.RowCount()) )

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.