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