Files
EmailBill/Repository/AGENTS.md
SunCheng b71eadd4f9
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 26s
Docker Build & Deploy / Deploy to Production (push) Successful in 7s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
重构账单查询sql
2026-01-28 10:58:15 +08:00

1.6 KiB

REPOSITORY LAYER KNOWLEDGE BASE

Generated: 2026-01-28 Parent: EmailBill/AGENTS.md

OVERVIEW

Data access layer using FreeSql with BaseRepository pattern and global usings.

STRUCTURE

Repository/
├── BaseRepository.cs           # Generic repository base
├── GlobalUsings.cs            # Common imports
├── BudgetRepository.cs         # Budget data access
├── TransactionRecordRepository.cs # Transaction data access
├── EmailMessageRepository.cs   # Email data access
└── TransactionStatisticsDto.cs # Statistics DTOs

WHERE TO LOOK

Task Location Notes
Base patterns BaseRepository.cs Generic CRUD operations
Budget data BudgetRepository.cs Budget queries and updates
Transaction data TransactionRecordRepository.cs Financial data access
Email data EmailMessageRepository.cs Email processing storage
Statistics TransactionStatisticsDto.cs Data transfer objects

CONVENTIONS

  • Inherit from BaseRepository for all repositories
  • Use GlobalUsings.cs for shared imports
  • Async/await pattern for all database operations
  • Method names: GetAllAsync, GetByIdAsync, InsertAsync, UpdateAsync
  • Return domain entities, not DTOs (except in query results)

ANTI-PATTERNS (THIS LAYER)

  • Never return anonymous types from methods
  • Don't expose FreeSql ISelect directly
  • Avoid business logic in repositories
  • No synchronous database calls
  • Don't mix data access with service logic

UNIQUE STYLES

  • Generic constraints: where T : BaseEntity
  • Fluent query building with FreeSql extension methods
  • Paged query patterns for large datasets