技能 dotnet-backend-patterns
📦

dotnet-backend-patterns

安全

Build production .NET backends with modern patterns

也可從以下取得: wshobson

Developing enterprise .NET applications requires mastering complex patterns for data access, dependency injection, and clean architecture. This skill provides battle-tested patterns for EF Core, Dapper, caching, and resilient API design.

支援: Claude Codex Code(CC)
🥈 78 白銀
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「dotnet-backend-patterns」。 Generate a repository pattern for Order entity

預期結果:

A complete OrderRepository class with async CRUD methods, using IDbConnectionFactory for connection management, proper CancellationToken support, and Dapper for query execution

正在使用「dotnet-backend-patterns」。 Optimize this EF Core query with multiple includes

預期結果:

Refactored query using AsNoTracking, AsSplitQuery for large collections, Select projection to DTO, and CompiledAsyncQuery for frequently executed queries

安全審計

安全
v1 • 2/24/2026

All 134 static analysis findings are false positives. The 'backtick execution' patterns (87 locations) are markdown code fences in documentation files. The 'weak cryptographic algorithm' findings (11 locations) are LINQ Expression<Func> patterns for the Specification pattern. The 'system reconnaissance' and 'filesystem' findings are normal C# property access and YAML frontmatter. This is a legitimate educational skill containing documentation and code examples for .NET backend development.

6
已掃描檔案
2,602
分析行數
0
發現項
1
審計總數
未發現安全問題
審計者: claude

品質評分

55
架構
100
可維護性
87
內容
50
社群
100
安全
91
規範符合性

你能建構什麼

Greenfield API Development

Build a new REST API from scratch with proper layering, dependency injection, and data access patterns.

Legacy Code Modernization

Refactor existing .NET Framework code to modern .NET patterns with improved performance and maintainability.

Performance Optimization Review

Review and optimize existing data access code for EF Core or Dapper-based applications.

試試這些提示

Repository Pattern Setup
Create a repository pattern implementation for a Product entity with CRUD operations using Entity Framework Core. Include async methods, proper disposal, and follow clean architecture principles.
Query Optimization Review
Review this EF Core query for performance issues. Identify N+1 problems, missing AsNoTracking calls, and opportunities for projection. Suggest optimized alternatives.
Dapper Micro-ORM Implementation
Implement a Dapper-based repository for high-performance read operations. Include connection management, parameter handling, and multi-mapping for joined tables.
Clean Architecture Service Layer
Design a service layer that orchestrates repository calls, caching, and validation. Apply dependency injection, CQRS separation, and resilience patterns for external calls.

最佳實務

  • Use AsNoTracking for read-only queries to reduce memory overhead
  • Register database contexts and connections as Scoped lifetime in DI
  • Apply the specification pattern for complex, composable query criteria

避免

  • Synchronous database calls in async code paths - always use Async methods
  • Loading entire entities when only specific columns are needed
  • Allowing lazy loading to trigger N+1 query problems

常見問題

When should I use Dapper instead of EF Core?
Use Dapper for performance-critical queries, complex SQL (CTEs, window functions), or read-heavy workloads. Use EF Core for rich domain models with relationships, change tracking needs, or when you prefer LINQ-to-SQL translation.
What is the specification pattern and when should I use it?
The specification pattern encapsulates query criteria in reusable classes. Use it for complex queries that are reused across your application, or when you need composable filter criteria with paging and sorting.
How do I prevent N+1 query problems in EF Core?
Use Include for eager loading related data, avoid lazy loading in loops, and use AsSplitQuery when including multiple collections to prevent cartesian explosion.
What is the recommended service lifetime for DbContext?
Scoped lifetime is recommended for DbContext in web applications. This ensures one instance per HTTP request, which is required for change tracking and identity map patterns.
How can I improve EF Core query performance?
Use AsNoTracking for read-only queries, project to DTOs with Select, use compiled queries for hot paths, apply proper indexing, and avoid client-side evaluation by ensuring queries can translate to SQL.
What caching strategy should I implement?
Use memory caching for small, frequently accessed data within a single instance. Use Redis for distributed caching across multiple instances. Always set expiration times and have cache miss fallback logic.