I have the following class
public class ProdutoTipo : IAuditable
{
public Guid ID { get; set; }
public string Nome { get; set; }
public string MiniNome { get; set; }
public string Descricao { get; set; }
public string Link { get; set; }
public int? Ordem { get; set; }
public virtual Foto ImagemExibicao { get; set; }
public virtual ICollection<ProdutoCategoria> Categorias { get; set; }
public DateTime CreatedAt { get; set; }
public string CreatedBy { get; set; }
public DateTime? UpdatedAt { get; set; }
public string UpdatedBy { get; set; }
public bool PaginaInicial { get; set; }
public ProdutoTipo() { ID = Guid.NewGuid(); }
}
I need a function that search the repository and returns true or false
But this search can be using any field of the class!
As far as I arrived
public bool Existe<TProperty, TComparer>(Expression<Func<ProdutoTipo, TProperty>> entityExpression, TComparer valor)
{
return Repository.ProdutoTipos.Any(p => /*entityExpression == valor ?????*/);
}
Would like to use the function like this ...
Existe(p => p.Nome, "Value to comparer!");
Thank you all!