Can I combine replace these methods in derived class with a method in the base class?
<p>I have methods like this:</p>

<pre><code>   public void AddOrUpdate(Product product)
    {
        try
        {
            _productRepository.AddOrUpdate(product);
        }
        catch (Exception ex)
        {
            _ex.Errors.Add("", "Error when adding product");
            throw _ex;
        }
    }


    public void AddOrUpdate(Content content)
    {
        try
        {
            _contentRepository.AddOrUpdate(content);
        }
        catch (Exception ex)
        {
            _ex.Errors.Add("", "Error when adding content");
            throw _ex;
        }
    }
</code></pre>

<p>plus more methods that differ only in the class passed to them.</p>

<p>Is there some way that I could code these methods in a base class rather than repeating the method in each derived class?  I was thinking something based on generics but I am not sure how to implement and also not sure how to pass in the _productRepository.</p>

<p>FYI here's the way _productRepository and _contentRepository are defined:</p>

<pre><code>    private void Initialize(string dataSourceID)
    {
        _productRepository = StorageHelper.GetTable&lt;Product&gt;(dataSourceID);
        _contentRepository = StorageHelper.GetTable&lt;Content&gt;(dataSourceID);
        _ex = new ServiceException();
    }
</code></pre>
