# Repository Pattern

*noun*

say it: **“rih-POZ-ih-tor-ee PAT-ern”** **/rɪˈpɒzɪtɔːri ˈpætərn/**

Putting all the code that stores and loads one kind of data in one class with simple methods like GetAll and Add.

## What is **Repository Pattern**?

The **Repository pattern** hides how data is stored behind a collection-like interface (`GetById`, `Add`, `Remove`). The rest of the app doesn't care whether it's SQL, a file or memory.

```csharp
public interface IBookRepository
{
    Book? GetById(int id);
    void Add(Book book);
}
```

## In a sentence

- “With the **repository pattern**, the controller calls products.GetAll() and never sees SQL.”

Level: Freelancer · [More OOP terms at this level](https://www.ask-codey.com/glossary?category=oop&level=4)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/repository-pattern
