CloudyWing.DatabaseFacade
0.1.0
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.5
This package targets .NET Framework 4.5. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CloudyWing.DatabaseFacade --version 0.1.0
NuGet\Install-Package CloudyWing.DatabaseFacade -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CloudyWing.DatabaseFacade" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CloudyWing.DatabaseFacade" Version="0.1.0" />
<PackageReference Include="CloudyWing.DatabaseFacade" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CloudyWing.DatabaseFacade --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CloudyWing.DatabaseFacade, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CloudyWing.DatabaseFacade@0.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CloudyWing.DatabaseFacade&version=0.1.0
#tool nuget:?package=CloudyWing.DatabaseFacade&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DatabaseFacade
DatabaseFacade 是用來簡化 ADO.NET 操作流程的資料庫工具,本身不具有操作資料庫的能力,需搭配對應的資料庫 Library 使用。
寫這個套件不是要讓大家使用,只是因為某個念想,想把過往寫得Respository DatabaseClients 完善,但後面發現命名不太適合,所以就重新開一個新的。
目前操作 ADO.NET 已經有一個很強大的套件 Dapper,如果不使用 Entity Framework 的話,我是建議使用 Dapper,DatabaseFacade 能在程式碼能給有需要的人做為參考就足夠了。
支援版本
- netstandard2.1
- netstandard2.0
- net45
使用教學
首先先在 NuGet 安裝你要使用的資料庫 Client,例如:「System.Data.SqlClient」、「Microsoft.Data.SqlClient」,然後在應用程式啟用時,設定 FacadeConfiguration,至少要設定對應的 DbFactory 和連線字串。
FacadeConfiguration.SetConfiguration(SqlClientFactory.Instance, "{資料庫連線字串}");
實際使用(以 SQL Server 語法為例)
using (CommandExecutor executor = new CommandExecutor()) {
executor.CommandText = "SELECT * FROM Table WHERE Id IN @Id";
executor.Parameters.Add("Id", new int[] { 1, 2, 3 })
DataTable dt = executor.CreateDataTable();
}
FacadeConfiguration可設定項目
| 屬性 | 型別 | 用途 |
|---|---|---|
| DefaultDbProviderFactory | DbProviderFactory | 用來建立 ADO.NET 相關物件 |
| DefaultConnectionString | string | 資料庫連線字串 |
| DefaultCommandTimeout | int | Command 的 Timeout 時間,預設為 30 秒 |
| DefaultKeepConnection | bool | 執行完 SQL 語法後,是否要關閉 SqlConnection |
| DefaultIsolationLevel | IsolationLevel | Transaction 的層級鎖,預設為 ReadCommitted |
| ParameterNamePrefix | string | 參數型別為 IEnumerable 時,產生的 ParameterName Prefix,預設「CloudyWing」 |
| OnCommandCreating | Action<ParameterCollection, string> | 可在建立 DbCommand 前加入自訂程式碼 |
| OnCommandCreated | Action<ParameterCollection, string> | 可在建立 DbCommand 後加入自訂程式碼 |
參考資料:
License
This project is MIT licensed.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.