1
People need to take all property of a class that is of class type. Ex:
public class Pessoa{
public virtual int? Id { get; set; }
public virtual MinhaClasse1 prop1{ get; set; }
public virtual MinhaClasse2 prop2{ get; set; }
}
I need to get the property prop1
and prop2
. I tried to do something like this below but it didn’t work:
var propertiess = pessoa.GetProperties().Where(
prop => prop.PropertyType.BaseType == typeof(object));
Where person would be a Generica entity (Tentity). For the purpose of assembling a ICriterion
for generic queries with class relationship.
foreach (PropertyInfo propriedade in listaPropriedadeClasse) {
var valorPropriedade = propriedade.GetValue(entity);
if (!valorPropriedade.IsNull()) {
criteria.Add(Property.ForName(propriedade.Name).Eq(valorPropriedade));
}
}
I had thought about this alternative too, but in my case I already solved, I marked the comment that solved my problem as an answer. VLW!
– Marcos Vinicius
but in your case you will have problem when you have a Datetime in your class.
– Pablo Tondolo de Vargas
I did a test here and did not return the fields of type Datetime. But I will be attentive to this question, if I will have to put more conditions in the search, I will adopt your suggestion. Vlw!
– Marcos Vinicius