# Repository Pattern

A pattern that hides data storage behind a simple collection-like interface.

## 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);
}
```

Level: Freelancer · [More OOP terms at this level](https://www.ask-codey.com/glossary/subjects/oop/freelancer)

Updated: September 27, 2026

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