The following code from my team mate works:
 public T Get<T, V>(V repo, string pk, string rk)
            where T : Microsoft.WindowsAzure.StorageClient.TableServiceEntity
            where V : IAzureTable<T>
        {
            try
            {
                var item = repo.GetPkRk(pk, rk);
                if (item == null) throw new Exception(); return (T)item;
            }
            catch (Exception ex)
            {
                _ex.Errors.Add("", typeof(T).Name + rk + " does not exist");
                throw _ex;
            }
        }
Calling code:
var account = base.Get<Account, IAzureTable<Account>>(_accountRepository, pk, rk);
Can it be simplified. The only type variable here is "Account" and I am wondering if the T and V types could be combined into one as V depends only on T.
Since the only place that V appears is in the signature, I'd have thought you could change it to:
public T Get<T>(IAzureTable<T> repo, string pk, string rk)
        where T : Microsoft.WindowsAzure.StorageClient.TableServiceEntity
But I don't have sample code handy to test this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With