ShadowSql.DDL
0.8.4.2-alpha
.NET 7.0
This package targets .NET 7.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
This is a prerelease version of ShadowSql.DDL.
dotnet add package ShadowSql.DDL --version 0.8.4.2-alpha
NuGet\Install-Package ShadowSql.DDL -Version 0.8.4.2-alpha
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="ShadowSql.DDL" Version="0.8.4.2-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ShadowSql.DDL" Version="0.8.4.2-alpha" />
<PackageReference Include="ShadowSql.DDL" />
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 ShadowSql.DDL --version 0.8.4.2-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ShadowSql.DDL, 0.8.4.2-alpha"
#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.
#addin nuget:?package=ShadowSql.DDL&version=0.8.4.2-alpha&prerelease
#tool nuget:?package=ShadowSql.DDL&version=0.8.4.2-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ShadowSql.DDL
- ShadowSql的DDL组件
- 主要用来支持CreateTable
- 搭配Dapper.Shadow.Core或Dapper.Shadow可以直接操作数据库的表
以下以Sqlite例
1. Build
- 构造TableSchema对象
- 通过TableSchemaBuilder类的DefineIdentity、DefineColumn、DefinColumns、DefineKeys等方法来定义表的列和主键等信息
var builder = new TableSchemaBuilder("Students", "tenant1")
.DefineIdentity("Id", "INTEGER")
.DefinColumns("TEXT", "Name");
TableSchema table = builder.Build();
var builder = new TableSchemaBuilder("Students", "tenant1");
builder.DefineColumn("Id", "INTEGER")
.ColumnType = ColumnType.Identity | ColumnType.Key;
builder.DefineColumn("Name", "TEXT");
TableSchema table = builder.Build();
var builder = new TableSchemaBuilder("user_role", "tenant1")
.DefineKeys("INT", "UserId", "RoleId")
.DefinColumns("DATETIME", "CreateTime");
TableSchema table = builder.Build();
2. CreateTable
ColumnSchema id = new("Id", "INTEGER") { ColumnType = ColumnType.Identity | ColumnType.Key };
ColumnSchema name = new("Name", "TEXT");
TableSchema table = new("Students", [id, name]);
CreateTable create = new(table);
// CREATE TABLE "Students"("Id" INTEGER PRIMARY KEY AUTOINCREMENT,"Name" TEXT)
3. 搭配Dapper.Shadow建表
ColumnSchema id = new("Id", "INTEGER") { ColumnType = ColumnType.Identity | ColumnType.Key };
ColumnSchema name = new("Name", "TEXT");
var result = new TableSchema("Students", [id, name])
.ToCreate()
.Execute(Executor);
4. DropTable
var drop = new DropTable("Students");
// DROP TABLE "Students"
5. 搭配Dapper.Shadow删掉
var result = new StudentTable()
.ToDrop()
.Execute(Executor);
6. 其他功能与Table类似
6.1 表Schema查询示例
UserTable table = new("Users", "tenant1");
var query = new TableQuery(table)
.And(table.Status.EqualValue(true));
var cursor = new TableCursor(query, 10, 20)
.Desc(table.Id);
var select = new CursorSelect(cursor)
.Select(table.Id, table.Name);
// MsSql生成sql: SELECT [Id],[Name] FROM [tenant1].[Users] WHERE [Status]=1 ORDER BY [Id] DESC OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY
public class UserTable(string tableName = "Users", string schema = "")
: TableSchema(tableName, [Defines.Id, Defines.Name, Defines.Status], schema)
{
#region Columns
public readonly ColumnSchema Id = Defines.Id;
new public readonly ColumnSchema Name = Defines.Name;
public readonly ColumnSchema Status = Defines.Status;
#endregion
class Defines
{
public static readonly ColumnSchema Id = new("Id") { ColumnType = ColumnType.Key };
public static readonly ColumnSchema Name = new("Name");
public static readonly ColumnSchema Status = new("Status");
}
}
6.2 DDL+表达式版查询示例
var select = new TableSchema("Users", [], "tenant1")
.ToSqlQuery<User>()
.Where(u => u.Status)
.Take(10, 20)
.Desc(u => u.Id)
.ToSelect();
// MsSql生成sql: SELECT * FROM [tenant1].[Users] WHERE [Status]=1 ORDER BY [Id] DESC OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY
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 is compatible. 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 is compatible. 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 is compatible. 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 | 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
- ShadowSql.Core (>= 0.8.4.1-alpha)
-
.NETStandard 2.1
- ShadowSql.Core (>= 0.8.4.1-alpha)
-
net7.0
- ShadowSql.Core (>= 0.8.4.1-alpha)
-
net8.0
- ShadowSql.Core (>= 0.8.4.1-alpha)
-
net9.0
- ShadowSql.Core (>= 0.8.4.1-alpha)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.8.4.2-alpha | 103 | 6/3/2025 |
0.8.4.1-alpha | 105 | 6/1/2025 |
0.8.4-alpha | 110 | 5/28/2025 |
0.8.3.1-alpha | 162 | 5/12/2025 |
0.8.3-alpha | 99 | 5/11/2025 |
0.8.2-alpha | 108 | 5/7/2025 |
0.8.1-alpha | 70 | 5/4/2025 |
0.8.0.3-alpha | 89 | 4/13/2025 |
0.8.0.1-alpha | 78 | 4/11/2025 |
0.7.0.1-alpha | 132 | 4/8/2025 |
0.7.0-alpha | 75 | 4/4/2025 |