ISqlWhereBuilder.RemoveWhere(string whereName) Method
.NET Standard 2.x
Removes the search condition (specified by name) from the WHERE clause.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
bool RemoveWhere(string whereName)
Parameters
whereName
System.String
The name for one or more search conditions in the WHERE clause.
Returns
System.Boolean
Returns true
if the removal is successful, and returns false
if the specified search condition name does not exist in the WHERE clause.
Examples
The following code example demonstrates how to use the RemoveWhere method to remove the specified condition from the WHERE clause.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlWhereBuilderExamples
{
public class RemoveWhereExample
{
private readonly SchoolContext _context;
public RemoveWhereExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example2()
{
// Declares SqlQueryBuilder.
ISqlQueryBuilder sqlQueryBuilder = new SqlQueryBuilder();
// Defines a WHERE condition.
ISqlWhereCondition whereCondition =
SqlBuilder.Where("CourseId", SqlBuilder.Parameter<int>("id"));
// Defines a SQL statement which uses the WHERE condition defined above.
// Specifies "where1" as the alias for the WHERE condition.
sqlQueryBuilder.SelectRaw("CourseID, Title")
.From("Course")
.Where(whereCondition, "where1");
Console.WriteLine("The SQL SELECT statement (before removed): \n {0}",
sqlQueryBuilder.ToSqlString(_context));
// Removes the condition "where1".
sqlQueryBuilder.RemoveWhere("where1");
Console.WriteLine();
Console.WriteLine("The SQL SELECT statement (after removed): \n {0}",
sqlQueryBuilder.ToSqlString(_context));
/*This code produces the following output:
The SQL SELECT statement (before removed):
SELECT
[CourseID],
[Title]
FROM [Course]
WHERE ([CourseId] = @id)
The SQL SELECT statement (after removed):
SELECT
[CourseID],
[Title]
FROM [Course]
*/
}
}
}
Applies to
.NET Standard
2.x