SqlTruncateBuilder
SqlTruncateBuilder<T> builds TRUNCATE TABLE statements.
Note: SQLite does not support TRUNCATE TABLE.
Build()throwsInvalidOperationExceptionwhen usingSqliteDialect. UseSqlDeleteBuilderwithAllowDeleteAll()instead.
var result = new SqlTruncateBuilder<User>(new SqlServerDialect())
.Table("Users")
.Build();
// → TRUNCATE TABLE [Users]
Table (Truncate)
Signature
SqlTruncateBuilder<T> Table(string tableName, string? schema = null)
Description
Sets the table to truncate. If not called, uses typeof(T).Name.
Tag (Truncate)
Signature
SqlTruncateBuilder<T> Tag(string description)
Description Adds a SQL comment header for traceability.
Build (Truncate)
Signature
SqlQueryResult Build()
Description
Builds and returns the TRUNCATE TABLE statement as a SqlQueryResult with an empty parameters dictionary.
Example with schema
new SqlTruncateBuilder<Order>(new SqlServerDialect())
.Table("Orders", schema: "dbo")
.Tag("Clear orders table")
.Build();
// → -- Clear orders table
// TRUNCATE TABLE [dbo].[Orders]
Advanced Example
var truncate = new SqlTruncateBuilder<User>()
.Table("Users")
.Build();