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.  [ 1 post ] 
Author Message
 Post subject: Problems with ICriteria
PostPosted: Fri Feb 13, 2009 1:18 pm 
Newbie

Joined: Fri Feb 13, 2009 1:14 pm
Posts: 1
Hi, I have some problems.. I'm getting a list of objects with some filters; the problem is that i do filter to objects inside the main object..

this is the code..
Code:
         ICriteria criterio = session.CreateCriteria(typeof(OrdenTrabajoIHidraulica));
          criterio.CreateAlias("Queja", "queja").CreateAlias("Contratista", "contratista");
          if (!string.IsNullOrEmpty(folio)) { criterio.Add(Expression.Like("Folio", folio)); }
          if (!string.IsNullOrEmpty(iZona)) { criterio.Add(Expression.Like("contratista.Sector.Zona", (TipoZona)Enum.Parse(typeof(TipoZona), idZonab)); }
          if (!string.IsNullOrEmpty(iConcepto)) { criterio.Add(Expression.Eq("queja.ConceptoQueja.Id", Convert.ToInt32(iConcepto))); }
          if (!string.IsNullOrEmpty(iPoblacion)) { criterio.Add(Expression.Eq("queja.Direccion.Poblacion.Id", Convert.ToInt32(iPoblacion))); }
          if (!string.IsNullOrEmpty(iColonia)) { criterio.Add(Expression.Eq("queja.Direccion.Colonia.Id", Convert.ToInt32(iColonia))); }
          if (!string.IsNullOrEmpty(iCalle)) { criterio.Add(Expression.Eq("queja.Direccion.Calle.Id", Convert.ToInt32(iCalle))); }
          if (!string.IsNullOrEmpty(iCalle2)) { criterio.Add(Expression.Eq("queja.Direccion.EntreCalle1.Id", Convert.ToInt32(iCalle2))); }
          if (!string.IsNullOrEmpty(iCalle3)) { criterio.Add(Expression.Eq("queja.Direccion.EntreCalle2.Id", Convert.ToInt32(iCalle3))); }
          if (!string.IsNullOrEmpty(direccion)) { criterio.Add(Expression.Like("queja.Direccion.NumeroExterior", direccion)); }
          criterio.Add(Expression.Not(Expression.Eq("Estatus", EstatusOTIHidraulica.Cancelada)));


The problems is this line..
Code:
if (!string.IsNullOrEmpty(iZona)) { criterio.Add(Expression.Like("contratista.Sector.Zona", (TipoZona)Enum.Parse(typeof(TipoZona), idZonab)); }


thats an enumType, but it saids that the property is no correct, I tried with some alias but nothing; if I put the property... contratista.Sector.Nombre y works, but with the property Zona of Sector it fails,, do i need to add other Alias?? thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.