Dubonnet 2.2.3
dotnet add package Dubonnet --version 2.2.3
NuGet\Install-Package Dubonnet -Version 2.2.3
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="Dubonnet" Version="2.2.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dubonnet" Version="2.2.3" />
<PackageReference Include="Dubonnet" />
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 Dubonnet --version 2.2.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dubonnet, 2.2.3"
#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 Dubonnet@2.2.3
#: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=Dubonnet&version=2.2.3
#tool nuget:?package=Dubonnet&version=2.2.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Base API
Retrieving entities by id
var product = db.Products.Get(1);
Retrieving all entities in a table
var products = db.Products.All().ToList();
Selecting some entities
var products = db.Products.WhereIn("id", new int[]{3,4,5}).All();
// 和下面的查询等价:
var same_products = db.Products.WhereRaw("id IN (?,?,?)",3,4,5).All();
Inserting entities
var product = new Product { Name = "Awesome bike", InStock = 4 };
int id = db.Products.Insert(product);
var products = new List<Product>
{
new Product { Name = "Awesome bike", InStock = 4 },
new Product { Name = "Awesome bike 2", InStock = 5 }
};
int count = db.Products.Insert(products);
Updating entities
var product = db.Products.Get(1);
product.LastUpdate = DateTime.Now;
db.Products.Update(product);
var products = db.Products.WhereIn("id", new int[]{1,2}).All().ToList();
products[0].LastUpdate = DateTime.Now;
products[1].LastUpdate = DateTime.Now;
db.Products.Update(products);
Removing entities
var product = db.Products.Get(1);
db.Products.Delete(product);
var products = db.Products.WhereIn("id", new int[]{1,2}).All();
db.Products.Delete(products);
Sharding
using System;
// 分库分表,假设产品按年分库,按月分表
// 当前2019年6月表名为`db_product_y2019`.`t_product_m201906`
int pageNo = 1, pageSize = 10;
DateTime someDay = DateTime.Now.AddMonths(-3);
var referName = products.CurrentName + someDay.ToString("yyyyMM");
var products = db.Products.Where("created_at", ">=", someDay.ToString("yyyy-MM-dd"));
// 找出类似db_product_y2019等数据库,并倒序排列数据库和表名
products.DbNameMatch = "db_product_y%";
products.IsTableNameDesc = true;
// 数据表名称限制为 t_products_m201906
products.tableFilter = (table, db) => table.CompareTo(referName) >= 0;
var count = unchecked((int)products.CountSharding());
// Console.WriteLine("Count={0} PageNo={1}", count, pageNo);
var rows = products.PaginateSharding(pageNo, pageSize);
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 was computed. |
.NET Framework | 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.
-
.NETStandard 2.0
- Dapper (>= 1.60.6)
- System.ComponentModel.Annotations (>= 4.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.