public async Task Delete(TId entity) { using (HotelDbContext context = new HotelDbContext()) { var deleteEntity = context.Find <T>(entity); context.Set <T>().Remove(deleteEntity); await context.SaveChangesAsync(); } }
public virtual TEntity FindById(int id, bool isTracked = true) { if (!isTracked) { context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; } TEntity item = context.Find <TEntity>(id); if (!isTracked) { context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.TrackAll; } return(item); }