I used Repository pattern that I saw on online tutorial...
Everything works fine except for find method, I have no idea how to work with this and I'm having hard time understanding Expressions or Func types. I used linq and lambda before but I'm begginer and still don't use it fluently...
public IEnumerable<TEntity> Find(Expression<Func<TEntity, bool>> predicate)
{
return Context.Set<TEntity>().Where(predicate);
}
I have this model class:
public partial class Artikl
{
[Browsable(false)]
public int IDArtikli { get; set; }
public string Barkod { get; set; }
[DisplayName("Šifra")]
public Nullable<int> Sifra { get; set; }
public string Naziv { get; set; }
[DisplayName("JM")]
public string JedinicaMjere { get; set; }
public decimal Tarifa { get; set; }
[DisplayName("Prodajna")]
public Nullable<decimal> ProdajnaCijena { get; set; }
[Browsable(false)]
public Nullable<bool> Flag { get; set; }
public Nullable<decimal> Kalo { get; set; }
[DisplayName("Nabavna")]
public Nullable<decimal> NabavnaCijena { get; set; }
[DisplayName("Veleprodajna")]
public Nullable<decimal> VeleprodajnaCijena { get; set; }
public Nullable<decimal> Zalihe { get; set; }
}
My question is how can I get the Artikl item based on property "Sifra". I have no idea how to call this method...
private void txtSifra_TextChanged(object sender, EventArgs e)
{
var artikl = _UnitOfWork.Artikl.Find(???);
txtNaziv.Text = artikl.Naziv;
}