次の継承階層があります。
public interface IRepository<T> : IDisposable
{
void Add(T model);
void Update(T model);
int GetCount();
T GetById(int id);
ICollection<T> GetAll();
}
public interface IAddressRepository : IRepository<Address>
{
}
そして、このコード:
var adrs = new Address[]{
new Address{Name="Office"}
};
using (IAddressRepository adrr = new AddressRepository())
foreach (var a in adrs)
adrr.Add(a);
ただし、このコードはコンパイルされません。次のエラー メッセージが表示されます。
Error 43
'Interfaces.IAddressRepository': type used in a using statement must be
implicitly convertible to 'System.IDisposable'
ただし、 の親はIAddressRepository
から継承しIDisposable
ます。
ここで何が起きてるの?コードをコンパイルするにはどうすればよいですか?