jak zaprojektować wzór repozytorium, aby później łatwo przejść na inny ORM?

Jestem nowym użytkownikiem wzorca repozytorium, ale próbowałem, moim celem jest stworzenie projektu, który pozwoli mi łatwo z kilkoma edycjami „wstrzyknięcia zależności lub zmiany konfiguracji”, aby móc przełączyć się na inny ORM bez dotykania innych warstw rozwiązania.

Dotarłem do tej implementacji:

a oto kod:

public interface IRepository<T>
{
    T Get(int key);
    IQueryable<T> GetAll();
    void Save(T entity);
    T Update(T entity);
    // Common data will be added here
}
public interface ICustomerRepository : IRepository<Customer> 
{
    // Specific operations for the customers repository
}
public class CustomerRepository : ICustomerRepository
{
    #region ICustomerRepository Members

    public IQueryable<Customer> GetAll()
    {
        DataClasses1DataContext context = new DataClasses1DataContext();
        return from customer in context.Customers select customer;
    }

    #endregion

    #region IRepository<Customer> Members

    public Customer Get(int key)
    {
        throw new NotImplementedException();
    }

    public void Save(Customer entity)
    {
        throw new NotImplementedException();
    }

    public Customer Update(Customer entity)
    {
        throw new NotImplementedException();
    }

    #endregion
}

użycie w mojej stronie aspx:

protected void Page_Load(object sender, EventArgs e)
    {
        IRepository<Customer> repository = new CustomerRepository();
        var customers = repository.GetAll();

        this.GridView1.DataSource = customers;
        this.GridView1.DataBind();
    }

Jak widziałeś w poprzednim kodzie, teraz używam LINQ do sql, a jak widzisz mój kod jest powiązany z LINQ do sql, jak zmienić ten projekt kodu, aby osiągnąć mój cel "być w stanie łatwo zmienić na inny ORM, na przykład do struktury podmiotu ADO.net lub poddźwiękowej ”

Proszę o poradę z prostym kodem przykładowym

questionAnswers(1)

yourAnswerToTheQuestion