I have a problem where I can not Delete or update entity in asp.net I want to automap objects using "AutoMapper" framework, but when I try to do it, it's cause error and I don't know why
/// Method for deleting entity in the Generic Repository
public void Delete<T>(int id) where T : class
{
try
{
var entity = _context.Set<T>().Find(id);
_context.Set<T>().Remove(entity);
_context.SaveChanges();
}
catch
{
/// Expection error
}
/// Interface
void Delete<T>(int id) where T : class;
/// I have use the AutoMapper framework for mapping objects
/// Also Mapper and Repository (interface) are injected in the constructor
public void Delete(IUser entity)
{
Repository.Delete(_mapper.Map<UserEntity>(entity));
}
/// Function for delete