-->
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: Help with ICriterion ToString
PostPosted: Thu Feb 01, 2007 6:45 pm 
Newbie

Joined: Mon Jul 17, 2006 5:57 pm
Posts: 1
[b]NHibernate version: 1.0.2.0 [/b]
[b]NHibernate Runtime version: 1.1.4322 [/b]

Hi,
I have an ICriterion array defined like this:

[code]ICriterion[] criteria;
criteria = new ICriterion[] { Expression.Or(Expression.Like("UsuarioId", "%" + pPatron + "%"), Expression.Or(Expression.Like("Nombre", "%" + pPatron + "%"), Expression.Like("Descripcion", "%" + pPatron + "%"))) };[/code]

And now I'm trying to find out how many records this criteria is going to get from the database (for paging purposes), so I'm building a query string like this:

[code]string query = "select count(*) from ...";
IQuery q = session.CreateQuery(query);
total = (int)q.UniqueResult();[/code]

My problem is that when I loop through the ICriterion array and invoke the ToString() function, it's returning the parameter values without quotes; and when I execute the code above, I get a syntax error.

Is there anyway to force NHibernate to use quotes when returning the ICriterion as a string?
Am I doing something wrong? or Does anyone know a better way to do what I'm trying?

Thanks in advance for your help !!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 3:39 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
ToString() is only there for debugging purposes, don't expect it to produce anything generally useful. You have to determine what type each criteria has and do something according to that, I guess. I'm not sure it would work in the end.


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.