Your problem is in this line:
return session.CreateCriteria(typeof(T))
.Add(Restrictions.Eq("pacienteid", pacienteId))
.List<T>();
I assume that T
in this case is Analises
. Analises
does not have a property named pacienteid
. Instead, it has a property named pac
. Replace "pacienteid"
with "pac.PacienteID"
. The fields that you use when creating the criteria should be the property names, not the column names.
return session.CreateCriteria(typeof(T))
.Add(Restrictions.Eq("pac.PacienteID", pacienteId))
.List<T>();
If you were filtering by some column other than Paciente
's primary key, Nome
for example, then a join would be necessary. In that case, you would do something like:
session.CreateCriteria(typeof(T))
.CreateAlias("pac", "p") // CreateAlias performs an inner join
.Add(Expression.Eq("p.Nome", name))
.List<T>()
But no join is needed to get to pac.PacienteID
.