ISqlBuilder.Reset() Method
.NET Standard 2.x
Clears the SQL statement and all of the SQL parameters defined in the current object.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
ISqlBuilder Reset();
Returns
Returns the current object.
Examples
The following code example demonstrates how to reset a SqlQueryBuilder
object.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlBuilderExamples
{
public class ResetExample
{
private SchoolContext _context;
public ResetExample(SchoolContext dataContext)
{
// Sets Data Context.
_context = dataContext;
}
public void Example()
{
// Builds a SQL statement.
var sqlBuilder = new SqlQueryBuilder();
sqlBuilder.Select("name")
.From("Department")
.WhereValue("DepartmentId", 1);
// Shows the SQL statement before calling the Reset method.
Console.WriteLine("The SQL SELECT statement (before reset): \n{0}",
sqlBuilder.ToSqlString(_context));
Console.WriteLine();
Console.WriteLine("Has Table (before reset): {0}", sqlBuilder.HasTable);
Console.WriteLine("Has Where (before reset): {0}", sqlBuilder.HasWhere);
// Resets sqlBuilder.
sqlBuilder.Reset();
Console.WriteLine();
Console.WriteLine("Has Table (after reset): {0}", sqlBuilder.HasTable);
Console.WriteLine("Has Where (after reset): {0}", sqlBuilder.HasWhere);
/*This code produces the following output:
The SQL SELECT statement (before reset):
SELECT
[name]
FROM [Department]
WHERE ([DepartmentId] = 1)
Has Table (before reset): True
Has Where (before reset): True
Has Table (after reset): False
Has Where (after reset): False
*/
}
}
}
Applies to
.NET Standard
2.x