Skip to content

[C#] Implement Repeated Reads Solution with request-scoped caching #306

@davideme

Description

@davideme

Task

Implement POST /lamps/bulk-toggle with request-scoped caching to avoid querying the same room multiple times.

Endpoint

POST /lamps/bulk-toggle

{
  "lampIds": ["uuid1", "uuid2", "uuid3"],
  "status": true
}

Functional Requirement

Must not query the same room multiple times even if multiple lamps belong to the same room.

Implementation Hints

  • Use a Dictionary<Guid, Room> as request-scoped cache
  • EF Core's change tracker may already cache entities within a DbContext scope
  • Verify behavior and add explicit caching if needed

Acceptance Criteria

  • Bulk toggle updates all specified lamps
  • Room validation occurs for each lamp (room must be active)
  • Same room is only queried once per request (verify with EF logging)
  • Returns 422 if any lamp belongs to deleted room

Parent Issue

Relates to #289

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions