mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 18:48:09 +08:00
Update sqlite truncate table
This commit is contained in:
@@ -260,8 +260,17 @@ namespace SqlSugar
|
|||||||
#region Methods
|
#region Methods
|
||||||
public override bool TruncateTable(string tableName)
|
public override bool TruncateTable(string tableName)
|
||||||
{
|
{
|
||||||
base.TruncateTable(tableName);
|
base.TruncateTable(tableName);//delete data
|
||||||
return this.Context.Ado.ExecuteCommand($"UPDATE sqlite_sequence SET seq = 0 WHERE name = '{tableName}'") > 0;
|
try
|
||||||
|
{
|
||||||
|
//clear sqlite identity
|
||||||
|
return this.Context.Ado.ExecuteCommand($"UPDATE sqlite_sequence SET seq = 0 WHERE name = '{tableName}'") > 0;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//if no identity sqlite_sequence
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///by current connection string
|
///by current connection string
|
||||||
|
@@ -256,8 +256,17 @@ namespace SqlSugar
|
|||||||
#region Methods
|
#region Methods
|
||||||
public override bool TruncateTable(string tableName)
|
public override bool TruncateTable(string tableName)
|
||||||
{
|
{
|
||||||
base.TruncateTable(tableName);
|
base.TruncateTable(tableName);//delete data
|
||||||
return this.Context.Ado.ExecuteCommand($"UPDATE sqlite_sequence SET seq = 0 WHERE name = '{tableName}'") > 0;
|
try
|
||||||
|
{
|
||||||
|
//clear sqlite identity
|
||||||
|
return this.Context.Ado.ExecuteCommand($"UPDATE sqlite_sequence SET seq = 0 WHERE name = '{tableName}'") > 0;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//if no identity sqlite_sequence
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///by current connection string
|
///by current connection string
|
||||||
|
Reference in New Issue
Block a user