ISqlQueryBuilder.RemoveSelect(string alias) Method
.NET Standard 2.x
Removes a column (specified by alias) from a selected list.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
ISqlQueryBuilder RemoveSelect(string alias);
Parameters
alias
System.String
The alias of a column.
Returns
SnapObjects.Data.ISqlQueryBuilder
Returns the current ISqlQueryBuilder
object.
Examples
The following code example demonstrates how to use the RemoveSelect(string alias) method to delete a column from sqlbuilder according to the column alias.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlQueryBuilderExamples
{
public class RemoveSelectExample
{
private SchoolContext _context;
public RemoveSelectExample(SchoolContext dataContext)
{
// Sets Data Context.
_context = dataContext;
}
public void Example()
{
// Declares SqlQueryBuilder.
var sqlbuilder = new SqlQueryBuilder();
// Defines a SQL statement; selects two columns from the "Department" table,
// and sets the alias for these columns.
sqlbuilder.Select("name", "name")
.Select("budget", "budget")
.From("Department", "dept");
// Deletes the column whose alias is "budget" from sqlbuilder.
sqlbuilder.RemoveSelect("budget");
// Converts to raw SQL for the database corresponding to the data context.
string sql = sqlbuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
SELECT
[name] AS [name]
FROM [Department] AS [dept]
*/
}
}
}
Applies to
.NET Standard
2.x