AIOffice_Database 1.0.0.87

AIOffice_Database

提供多資料庫 DbContext 與泛型 Repository 的注入方法,統一管理 EF Core 連線設定。

安裝與設定

1. 在 appsettings.json 加入連線字串

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=localhost;Port=5432;Database=ApplicationDB;Username=postgres;Password=123456",
    "AIOffice_Auth": "Host=localhost;Port=5432;Database=AIOfficeAuth;Username=postgres;Password=123456",
    "AIOffice_Platform": "Host=localhost;Port=5432;Database=AIOfficePlatform;Username=postgres;Password=123456"
  }
}

2. 在 Program.cs 中註冊

var builder = WebApplication.CreateBuilder(args);

// 加入資料庫注入 (包含三個 DbContext + 泛型 Repository)
builder.Services.AddDBDI(builder.Configuration);

var app = builder.Build();
app.Run();

3. 可用的 DbContext

  • ApplicationDbContext → 讀取 DefaultConnection\
  • DataBase_AIOffice_AuthContext → 讀取 AIOffice_Auth\
  • DataBase_AIOffice_PlatformContext → 讀取 AIOffice_Platform

4. 已註冊的 Repository

  • IDBRepository<TEntity, TKey, TContext>\
  • 對應實作為 DBSRepository<TEntity, TKey, TContext>

範例使用

public class UserService
{
    private readonly IDBRepository<User, Guid, DataBase_AIOffice_AuthContext> _userRepo;

    public UserService(IDBRepository<User, Guid, DataBase_AIOffice_AuthContext> userRepo)
    {
        _userRepo = userRepo;
    }

    public async Task<User?> GetUserAsync(Guid id)
    {
        return await _userRepo.FindAsync(id);
    }
}

No packages depend on AIOffice_Database.

Version Downloads Last updated
1.0.0.139 11 05/24/2026
1.0.0.138 9 12/15/2025
1.0.0.137 2 12/15/2025
1.0.0.136 2 12/15/2025
1.0.0.135 2 12/15/2025
1.0.0.134 5 12/11/2025
1.0.0.133 6 12/11/2025
1.0.0.132 4 12/05/2025
1.0.0.131 2 12/05/2025
1.0.0.130 5 11/14/2025
1.0.0.129 5 11/13/2025
1.0.0.128 8 11/10/2025
1.0.0.127 4 11/10/2025
1.0.0.126 2 11/10/2025
1.0.0.125 4 11/10/2025
1.0.0.124 2 11/10/2025
1.0.0.123 6 11/05/2025
1.0.0.122 5 11/05/2025
1.0.0.121 4 11/05/2025
1.0.0.120 4 11/04/2025
1.0.0.119 5 11/03/2025
1.0.0.118 5 11/03/2025
1.0.0.117 3 11/03/2025
1.0.0.116 2 10/31/2025
1.0.0.115 5 10/31/2025
1.0.0.114 3 10/30/2025
1.0.0.113 2 10/30/2025
1.0.0.112 3 10/30/2025
1.0.0.111 3 10/30/2025
1.0.0.110 3 10/29/2025
1.0.0.109 3 10/29/2025
1.0.0.108 3 10/29/2025
1.0.0.107 3 10/28/2025
1.0.0.106 3 10/28/2025
1.0.0.105 2 10/28/2025
1.0.0.104 2 10/28/2025
1.0.0.103 10 10/27/2025
1.0.0.102 7 10/22/2025
1.0.0.101 1 10/22/2025
1.0.0.100 1 10/22/2025
1.0.0.99 4 10/22/2025
1.0.0.98 4 10/21/2025
1.0.0.97 2 10/21/2025
1.0.0.96 3 10/20/2025
1.0.0.95 3 10/20/2025
1.0.0.94 6 10/20/2025
1.0.0.93 2 10/20/2025
1.0.0.92 4 10/17/2025
1.0.0.91 3 10/17/2025
1.0.0.90 3 10/17/2025
1.0.0.89 2 10/17/2025
1.0.0.88 3 10/16/2025
1.0.0.87 7 10/16/2025
1.0.0.86 2 10/16/2025
1.0.0.85 3 10/16/2025
1.0.0.84 2 10/16/2025
1.0.0.83 3 10/16/2025
1.0.0.82 6 10/15/2025
1.0.0.81 2 10/15/2025
1.0.0.80 2 10/14/2025
1.0.0.79 1 10/14/2025
1.0.0.78 2 10/14/2025
1.0.0.77 2 10/14/2025
1.0.0.76 2 10/14/2025
1.0.0.75 3 10/14/2025
1.0.0.74 6 10/14/2025
1.0.0.73 8 10/14/2025