SqlQuery class

namespace: Serenity.Data   assemblySerenity.Net.Data

SQL query string builder

public class SqlQuery : QueryWithParams, IFilterableQuery, IGetExpressionByName, ISqlQuery, 
    ISqlQueryExtensible

Public Members

name description
SqlQuery() Creates a new SqlQuery instance.
CountRecords { get; set; } Gets/sets the flag to get the total record count when paging is used by SKIP/TAKE. A secondary query without SKIP/TAKE is generated to get total record count, when this property is true.
Text { get; } Gets current query text.
Clone() Creates a clone of the query.
Dialect(…) Sets the dialect (SQL server type / version) for query.
Distinct(…) Sets DISTINCT flag.
EnsureJoin(…) Ensures the join.
EnsureJoinsInExpression(…) Ensures the joins in expression. For this to work, into row must provide a list of joins and their expressions.
ForJson(…) Adds a FOR JSON statement to the query.
ForXml(…) Adds a FOR XML statement to the query.
From(…) Adds a table to the FROM statement. When it is called more than once, puts a comma between table names (cross join) (4 methods)
FullTextSearchJoin(…) Creates the required join for full text search in MSSQL.
GroupBy(…) Adds a field name or an SQL expression to the GROUP BY clause. (2 methods)
Having(…) Adds an SQL expression to the GROUP BY clause.
InnerJoin(…) Adds an inner join to the query.
Join(…) Joins the specified join.
LeftJoin(…) Adds a LEFT JOIN to the query. (2 methods)
OmitParens(…) Sets the omit parens flag, e.g. to exclude parens. Parens are normally only included for sub queries.
OrderBy(…) Adds a field name or an SQL expression to the ORDER BY clause. (2 methods)
OrderByFirst(…) Inserts a field name or an SQL expression to the start of ORDER BY clause.
RightJoin(…) Adds a right join to the query. (2 methods)
Select(…) Adds a field name or an SQL expression to the SELECT statement. (6 methods)
SelectMany(…) Adds field names or SQL expressions to the SELECT statement.
Skip() Gets current SKIP value.
Skip(…) Sets SKIP value. Used for paging.
SubQuery() Creates a new query that shares parameter dictionary with this query.
Take() Gets TAKE/TOP value.
Take(…) Sets TAKE/TOP value. Used for paging.
override ToString() Formats SQL Query as string. If paging is used and skip requested, multiple queries might be created one after each other.
Union(…) Adds a union to query with the specified union type.
Where(…) Adds an expression to WHERE clause. If query already has a WHERE clause, inserts AND between existing one and new one. (2 methods)
static ToString(…) Formats SQL Query as string. If paging is used and skip requested, multiple queries might be created one after each other.
class Column Holds information about a column in SELECT clause.

See Also