I'm working with Entity Framewor app windowsw forms, I need to return an enbity for that I'm calling the Single method but I do not know how to use it
What I try to implement if it exists returns an entity and does not exist, it returns a null, in other words if it exists, it returns the entity and I update it and if it does not exist it returns null and I create.
public void Create(Talla entity)
{
if(_tallaRepository.Single()
//if (_tallaRepository.Existe(entity.TallaId))
_tallaRepository.Update(entity);
else
_tallaRepository.Create(entity);
}
This method returns an entity instead of true or false
public bool Existe(int codigo)
{
int result = Context.Tallas.Where(x => x.TallaId == codigo).Count();
if (result == 0)
return false;
else
return true;
}