public void Delete(object id) { var property = _context.FindPrimaryKey(typeof(TEntity)); if (property != null) { var entity = Activator.CreateInstance <TEntity>(); property.PropertyInfo.SetValue(entity, id); ((DbContext)_context).Entry(entity).State = EntityState.Deleted; } else { var entity = Entities.Find(id); if (entity != null) { Delete(entity); } } }
private string KeyPropertiesCache(Type type) { return(_context.FindPrimaryKey(type).Name); }