SqlBuilder.Select(string column, string alias = "") Method
.NET Standard 2.x | Current Version (1.0.1)
Creates an ISqlQueryBuilder
object for building a SQL SELECT statement, and adds a column to the select list of the SELECT clause. You can also specify an alias for this column.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public static ISqlQueryBuilder Select(string column, string alias = "");
Parameters
column
System.String
The name of the column to be added to the select list of the SELECT clause.
alias
System.String
(Optional) The alias of the column.
The default value is an empty string.
Returns
SnapObjects.Data.ISqlQueryBuilder
Returns a newly created ISqlQueryBuilder
object which can be used to build the SQL SELECT statement.
Examples
The following code example demonstrates how to use the Select(string column, string alias = "") method to retrieve the Name values from the "Department" table and specify an alias for the Name column.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.SqlBuilderExamples
{
public class SelectExample
{
private SchoolContext _context;
public SelectExample(SchoolContext dataContext)
{
// Sets Data Context.
_context = dataContext;
}
public void Example1()
{
// Creates a SQL statement to retrieve the Name values from the "Department" table, and specifies "nm" as the alias for the Name column.
var query = SqlBuilder
.Select("Name", "nm")
.From("Department");
// Converts to raw SQL for the database corresponding to the data context.
string sql = query.ToSqlString(_context);
Console.WriteLine(sql);
/*This code example produces the following output:
SELECT
[Name] AS [nm]
FROM [Department]
*/
}
}
}
Applies to
.NET Standard
2.x