Table of Contents

Class TCQLExpression

Namespace
TimeCockpit.Data.QueryLanguage.Syntax
Assembly
TimeCockpit.Data.dll

Static class producing TCQL expressions and queries.

public static class TCQLExpression
Inheritance
Object
TCQLExpression
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()

Fields

VersionInfoOnly

default version info only instance.

public static readonly QueryOptions VersionInfoOnly

Field Value

QueryOptions

Properties

IncludeAll

Gets the single include all (IncludeAll).

public static EntitySourceIncludeRelation IncludeAll { get; }

Property Value

EntitySourceIncludeRelation

Null

Gets the null constant.

public static NullConstant Null { get; }

Property Value

NullConstant

Methods

Aggregate(AggregationFunctionCallType, Expression)

Creates a Aggregate function call.

public static AggregationFunctionCall Aggregate(AggregationFunctionCallType aggregation, Expression expression)

Parameters

aggregation AggregationFunctionCallType

The aggregation type.

expression Expression

The expression to aggregate.

Returns

AggregationFunctionCall

Returns a new Aggregation Function call that can be used in a select new with.

Average(Expression)

Creates a Avg aggregation function call.

public static AggregationFunctionCall Average(Expression expression)

Parameters

expression Expression

The expression to average.

Returns

AggregationFunctionCall

Returns a new Aggregation Function call that can be used in a select new with.

Constant(Boolean)

Shortcut method to True and False.

public static BooleanConstant Constant(bool value)

Parameters

value Boolean

The value of the constant.

Returns

BooleanConstant

Returns True if value is true, False otherwise.

Constant(Decimal)

Creates a decimal constant.

public static DecimalConstant Constant(decimal numericValue)

Parameters

numericValue Decimal

The numeric value.

Returns

DecimalConstant

Returns a new DecimalConstant.

Constant(Guid)

Creates a guid constant.

public static GuidConstant Constant(Guid guid)

Parameters

guid Guid

The value of the constant.

Returns

GuidConstant

Returns a new GuidConstant.

Constant(String)

Creates a string constant.

public static StringConstant Constant(string stringValue)

Parameters

stringValue String

The value of the string constant.

Returns

StringConstant

Returns a new StringConstant

Count()

Creates a count aggregation.

public static AggregationFunctionCall Count()

Returns

AggregationFunctionCall

Returns a new AggregatinoFunctionCall AST node representing a count.

CountDistinct(Expression)

Creates a CountDistinct aggregate function AST node.

public static AggregationFunctionCall CountDistinct(Expression expression)

Parameters

expression Expression

The expression to aggrgate.

Returns

AggregationFunctionCall

Returns a new AggregationFunctionCall AST node describing the Max aggregation.

DateConstant(DateTime)

Creates a DateConstant.

public static DateConstant DateConstant(DateTime date)

Parameters

date DateTime

the date value of the constant.

Returns

DateConstant

Returns a new DateConstant(DateTime).

DateTimeConstant(DateTime)

Creates a DateTimeConstant.

public static DateTimeConstant DateTimeConstant(DateTime dateTime)

Parameters

dateTime DateTime

The value of the constant.

Returns

DateTimeConstant

Returns a new DateTimeConstant(DateTime).

From(String, EntitySourceInclude[])

Creates a table source with optinal include.

public static EntitySource From(string entityName, params EntitySourceInclude[] includes)

Parameters

entityName String

The entity name to select from.

includes EntitySourceInclude[]

The optional include sources.

Returns

EntitySource

Returns a new EntitySource AST node.

FromBackReference(String, String)

Creates a QuerySource from a back reference.

public static BackReferenceSource FromBackReference(string backReferenceName, string alias = null)

Parameters

backReferenceName String

The name of the back reference to select from.

alias String

The alias (optional) to refer to.

Returns

BackReferenceSource

Returns a new BackReferenceSource.

FromBackReference(String[], String)

Creates a QuerySource from a back reference.

public static BackReferenceSource FromBackReference(string[] backReferencePath, string alias = null)

Parameters

backReferencePath String[]

The path of the back reference.

alias String

The (optional) alias

Returns

BackReferenceSource

Returns a new BackReferenceSource.

FromDeadOf(String)

Returns a new DeadOf AST Node / query source.

public static DeadOfSource FromDeadOf(string entityName)

Parameters

entityName String

The name of the entity whose dead to select.

Returns

DeadOfSource

Returns a new dead of source.

FunctionCall(String, Expression[])

Creates a function call object.

public static FunctionCall FunctionCall(string functionName, params Expression[] parameters)

Parameters

functionName String

The name of the function to call.

parameters Expression[]

The parameter expressions to the function.

Returns

FunctionCall

Returns a new instance of FunctionCall(String, Expression[]).

IncludeConditional(String, Expression, String)

Creates a conditional include.

public static EntitySourceIncludeConditional IncludeConditional(string backReferenceName, Expression condition, string backReferenceAliasName = null)

Parameters

backReferenceName String

The name of the backreference.

condition Expression

The filter condition.

backReferenceAliasName String

The alias name for the backreference.

Returns

EntitySourceIncludeConditional

Returns a new EntitySourceIncludeConditional AST node.

IncludeRelation(String)

Creates a EntitySourceIncludeRelation

public static EntitySourceIncludeRelation IncludeRelation(string relationName)

Parameters

relationName String

The name of the relation to include.

Returns

EntitySourceIncludeRelation

Returns a new EntitySourceIncludeRelation AST node.

MakeBinary(BinaryOperator, Expression, Expression)

Creates a binary expression combining the left hand and the right hand expression with the operator given.

public static BinaryExpression MakeBinary(BinaryOperator op, Expression leftHand, Expression rightHand)

Parameters

op BinaryOperator

The operator to use.

leftHand Expression

The left hand argument to the operator.

rightHand Expression

the right hand argument to the operator.

Returns

BinaryExpression

Returns a new BinaryExpression.

Max(Expression)

Creates a Max aggregate function AST node.

public static AggregationFunctionCall Max(Expression expression)

Parameters

expression Expression

The expression to aggrgate.

Returns

AggregationFunctionCall

Returns a new AggregationFunctionCall AST node describing the Max aggregation.

Member(String, String)

Creates a new member declaration for an identifier member.

public static MemberDeclarationNamedIdentifier Member(string name, string identifier)

Parameters

name String

The name of the new member.

identifier String

The identifier the member references.

Returns

MemberDeclarationNamedIdentifier

Returns a new instance of the MemberDeclarationNamedIdentifier AST node.

Member(String, Expression)

Creates a member declaration for an expression member.

public static MemberDeclarationNamedExpression Member(string name, Expression expression)

Parameters

name String

The name of the new member.

expression Expression

The expression of the member.

Returns

MemberDeclarationNamedExpression

Returns a new instance of a MemberDeclarationNamedExpression AST node.

Member(MemberAccess)

Creates a forwarded member declaration used in a select new with. E.g. In

From X In Timesheet Select New With { X.BeginTime } 

"X.BeginTime" refers to such a member declaration.

public static MemberDeclarationForwarded Member(MemberAccess memberAccess)

Parameters

memberAccess MemberAccess

The member access describing the forwarded property.

Returns

MemberDeclarationForwarded

Returns a new MemberDeclarationForwarded AST Node.

Min(Expression)

Creates a Min aggregate function AST node.

public static AggregationFunctionCall Min(Expression property)

Parameters

property Expression

The property to aggrgate.

Returns

AggregationFunctionCall

Returns a new AggregationFunctionCall AST node describing the Min aggregation.

OrderBy(Expression, SortDirection)

Creates a new Orderby expression.

public static OrderByExpression OrderBy(Expression sortExpression, SortDirection sortOrder)

Parameters

sortExpression Expression

The expression producing the property to sort by.

sortOrder SortDirection

The sort order, Ascending or Descending.

Returns

OrderByExpression

Returns a new OrderByExpression.

OrderBy(OrderByExpression, OrderByExpression[])

Creates a new order by.

public static OrderBy OrderBy(OrderByExpression firstExpression, params OrderByExpression[] additionalOrderBys)

Parameters

firstExpression OrderByExpression

The first expression to order by.

additionalOrderBys OrderByExpression[]

The second expression to order by.

Returns

OrderBy

Returns a new instance of the OrderBy node.

Parameter(String)

Creates a new instance of the Parameter(String) class. Note that the leading @ to parameter names is part of the grammar and therefore may not be part of the parameterName.

public static Parameter Parameter(string parameterName)

Parameters

parameterName String

The name of the parameter.

Returns

Parameter

Returns a new instance of the Parameter(String) class.

ParseExpression(String)

Uses the existing AST to convert a tcql expression to a new expression representation.

public static Expression ParseExpression(string expression)

Parameters

expression String

The expression to parse.

Returns

Expression

Returns the expression tree.

ParseQuery(String)

Uses the existing ast to convert a tcql query to an sytanx query representation.

public static Query ParseQuery(string query)

Parameters

query String

The query to parse.

Returns

Query

Returns the Syntax Tree of the query.

Property(String)

Creates a new instance of the MemberAccess class.

public static MemberAccess Property(string property)

Parameters

property String

the name of the property.

Returns

MemberAccess

Returns a new MemberAccess.

Property(String[])

Constructs a member access with the path elements as arguments.

public static MemberAccess Property(params string[] propertyPath)

Parameters

propertyPath String[]

the property path.

Returns

MemberAccess

Returns a new MemberAccess.

Query(String)

Builds a simple select all from a table name query.

public static Query Query(string entityName)

Parameters

entityName String

The name of the entity / backrefernce to query from.

Returns

Query

Returns the Query representing the query.

Query(String, Expression)

Creates a select query with a where condition and an implicit select alias. E.g.

var query = TcqlExpression.Query(
	"User",
	TcqlExpression.MakeBinary(
		TcqlExpressionType.Equal,
		TcqlExpression.Property("FirstName"),
		TcqlExpression.Constant("Max")));

produces

From U In User Where U.FirstName = ‘Max’ Select U
public static Query Query(string entityName, Expression whereCondition)

Parameters

entityName String

The name of the entity / back reference to query.

whereCondition Expression

The where condition of the query.

Returns

Query

Returns a new query.

Query(String, QuerySource, Expression, OrderBy, Select, QueryOptions)

Creates a query with aliasname, querysource, where condition, orderby, select statement and query options.

public static Query Query(string aliasName, QuerySource source, Expression where, OrderBy orderBy, Select select, QueryOptions options = null)

Parameters

aliasName String

The alias name.

source QuerySource

The query source.

where Expression

The query filter.

orderBy OrderBy

The orderby clause.

select Select

The select clause.

options QueryOptions

The options.

Returns

Query

Returns a new query.

Query(String, QuerySource, Expression, OrderBy, SkipAndTake, Select, QueryOptions)

Creates a query with aliasname, querysource, where condition, orderby, select statement and query options.

public static Query Query(string aliasName, QuerySource source, Expression where, OrderBy orderBy, SkipAndTake skipAndTake, Select select, QueryOptions options = null)

Parameters

aliasName String

The alias name.

source QuerySource

The query source.

where Expression

The query filter.

orderBy OrderBy

The orderby clause.

skipAndTake SkipAndTake

The skip and take clause.

select Select

The select clause.

options QueryOptions

The options.

Returns

Query

Returns a new query.

Query(String, QuerySource, Select)

Creates a new query with an alias, a query source and a select.

public static Query Query(string alias, QuerySource source, Select select)

Parameters

alias String

The alias that refers to the source.

source QuerySource

The source to select from.

select Select

The select arguments.

Returns

Query

Returns a new query.

Query(String, Select)

Creates a new Query without a where condition, but a select list / select alias choice.

public static Query Query(string entityName, Select select)

Parameters

entityName String

The name of the entity to select.

select Select

The select clause.

Returns

Query

Returns a new query.

Query(QuerySource)

Creates a select all from a entity source.

public static Query Query(QuerySource source)

Parameters

source QuerySource

The source of the query.

Returns

Query

Returns the query returned by Query(String, QuerySource, Expression, OrderBy, Select, QueryOptions)

Query(QuerySource, Expression, Select)

Creates a query with a query source, a where condition and a select clause.

public static Query Query(QuerySource source, Expression where, Select select)

Parameters

source QuerySource

The query source.

where Expression

The where condition.

select Select

The select clause.

Returns

Query

Returns the new query.

Query(QuerySource, Select)

Creates a new query without a where clause, select options or an alias.

public static Query Query(QuerySource source, Select select)

Parameters

source QuerySource

The source to select from.

select Select

The select clause.

Returns

Query

Returns a new query.

SelectAlias(String, Int32)

Creates a select alias.

public static SelectAlias SelectAlias(string aliasName = null, int top = -1)

Parameters

aliasName String

The (optional) name of the alias to select.

top Int32

the (optional) top count

Returns

SelectAlias

Returns a new select alias.

SelectNewWith(Int32, MemberDeclaration[])

Creates a new SelectNewWith AST node.

public static SelectNewWith SelectNewWith(int top, params MemberDeclaration[] members)

Parameters

top Int32

The top limit, use -1 to set to unlimited.

members MemberDeclaration[]

The members of the select new with list.

Returns

SelectNewWith

Returns a new instance of the SelectNewWith AST node.

SelectNewWith(String, MemberDeclaration[])

creates a new SelectNewWith AST node with a specified type as in

From T In Timesheet Select New Project With { .Title = "My New Project" }

In this sample, the type would be set to "Project" and the member to a collection holding a single MemberDeclarationNamedExpression("Title", TCQLExpression.Constant("My New Project")).

public static SelectNewWith SelectNewWith(string type, params MemberDeclaration[] members)

Parameters

type String

The type of the entity.

members MemberDeclaration[]

The members that will be actually set.

Returns

SelectNewWith

Returns a new instance of the SelectNewWith AST node.

SelectNewWith(MemberDeclaration[])

Creates a SelectNewWith AST node. Forwards to SelectNewWith(Int32, MemberDeclaration[]).

public static SelectNewWith SelectNewWith(params MemberDeclaration[] members)

Parameters

members MemberDeclaration[]

The members of the SelectNewWith.

Returns

SelectNewWith

Returns the result of SelectNewWith(Int32, MemberDeclaration[]).

Set(String, String)

Creates a named set reference.

public static NamedSetReference Set(string setName, string propertyName = null)

Parameters

setName String

The name of the set to reference.

propertyName String

The name of the property.

Returns

NamedSetReference

Returns the named set reference.

Set(Expression[])

Creats an explicit set expression.

public static ExplicitSet Set(params Expression[] elementExpressions)

Parameters

elementExpressions Expression[]

The expressions producing the elements.

Returns

ExplicitSet

Returns a new Instance of the ExplicitSet.

SkipAndTake(Int32, Int32)

Creates a skip and take structure.

public static SkipAndTake SkipAndTake(int skip, int take)

Parameters

skip Int32

The skip value.

take Int32

the take value, -1 if unbound.

Returns

SkipAndTake

Returns the SkipAndTake(Int32, Int32) instance.

Sum(Expression)

Creates a Sum aggregation function call.

public static AggregationFunctionCall Sum(Expression expression)

Parameters

expression Expression

The expression to sum.

Returns

AggregationFunctionCall

Returns a new Aggregation Function call that can be used in a select new with.