Type used in a using statement must be implicitly convertible to 'System.IDisposable'

    public interface ICustomerRepository:
    {
        List<Customer> GetAll();
        Customer Get(int customerId);
        void Add(Customer customer);
    }
            using (var repository = IoC.Get<ICustomerRepository>())
            {
                ......
            }

会报错:Type used in a using statement must be implicitly convertible to 'System.IDisposable'

将接口从IDisposable继承即可:

    public interface ICustomerRepository:IDisposable
    {
        List<Customer> GetAll();
        Customer Get(int customerId);
        void Add(Customer customer);
    }

 

 

posted @ 2014-06-19 14:39  邹邹  Views(1138)  Comments(0)    收藏  举报