Class TCQLExpression
- Assembly
- TimeCockpit.Data.dll
Static class producing TCQL expressions and queries.
public static class TCQLExpression
- Inheritance
-
ObjectTCQLExpression
- 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
Properties
IncludeAll
Gets the single include all (IncludeAll).
public static EntitySourceIncludeRelation IncludeAll { get; }
Property Value
Null
Gets the null constant.
public static NullConstant Null { get; }
Property Value
Methods
Aggregate(AggregationFunctionCallType, Expression)
Creates a Aggregate function call.
public static AggregationFunctionCall Aggregate(AggregationFunctionCallType aggregation, Expression expression)
Parameters
aggregationAggregationFunctionCallTypeThe aggregation type.
expressionExpressionThe 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
expressionExpressionThe expression to average.
Returns
- AggregationFunctionCall
Returns a new Aggregation Function call that can be used in a select new with.
Constant(Boolean)
public static BooleanConstant Constant(bool value)
Parameters
valueBooleanThe value of the constant.
Returns
Constant(Decimal)
Creates a decimal constant.
public static DecimalConstant Constant(decimal numericValue)
Parameters
numericValueDecimalThe numeric value.
Returns
- DecimalConstant
Returns a new DecimalConstant.
Constant(Guid)
Creates a guid constant.
public static GuidConstant Constant(Guid guid)
Parameters
guidGuidThe value of the constant.
Returns
- GuidConstant
Returns a new GuidConstant.
Constant(String)
Creates a string constant.
public static StringConstant Constant(string stringValue)
Parameters
stringValueStringThe 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
expressionExpressionThe 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
dateDateTimethe date value of the constant.
Returns
- DateConstant
Returns a new DateConstant(DateTime).
DateTimeConstant(DateTime)
Creates a DateTimeConstant.
public static DateTimeConstant DateTimeConstant(DateTime dateTime)
Parameters
dateTimeDateTimeThe 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
entityNameStringThe entity name to select from.
includesEntitySourceInclude[]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
backReferenceNameStringThe name of the back reference to select from.
aliasStringThe 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
backReferencePathString[]The path of the back reference.
aliasStringThe (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
entityNameStringThe 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
functionNameStringThe name of the function to call.
parametersExpression[]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
backReferenceNameStringThe name of the backreference.
conditionExpressionThe filter condition.
backReferenceAliasNameStringThe 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
relationNameStringThe 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
opBinaryOperatorThe operator to use.
leftHandExpressionThe left hand argument to the operator.
rightHandExpressionthe 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
expressionExpressionThe 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
nameStringThe name of the new member.
identifierStringThe 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
nameStringThe name of the new member.
expressionExpressionThe 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
memberAccessMemberAccessThe 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
propertyExpressionThe 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
sortExpressionExpressionThe expression producing the property to sort by.
sortOrderSortDirectionThe 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
firstExpressionOrderByExpressionThe first expression to order by.
additionalOrderBysOrderByExpression[]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
parameterNameStringThe 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
expressionStringThe 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
queryStringThe 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
propertyStringthe 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
propertyPathString[]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
entityNameStringThe 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
entityNameStringThe name of the entity / back reference to query.
whereConditionExpressionThe 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
aliasNameStringThe alias name.
sourceQuerySourceThe query source.
whereExpressionThe query filter.
orderByOrderByThe orderby clause.
selectSelectThe select clause.
optionsQueryOptionsThe 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
aliasNameStringThe alias name.
sourceQuerySourceThe query source.
whereExpressionThe query filter.
orderByOrderByThe orderby clause.
skipAndTakeSkipAndTakeThe skip and take clause.
selectSelectThe select clause.
optionsQueryOptionsThe 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
aliasStringThe alias that refers to the source.
sourceQuerySourceThe source to select from.
selectSelectThe 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
entityNameStringThe name of the entity to select.
selectSelectThe 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
sourceQuerySourceThe 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
sourceQuerySourceThe query source.
whereExpressionThe where condition.
selectSelectThe 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
sourceQuerySourceThe source to select from.
selectSelectThe 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
aliasNameStringThe (optional) name of the alias to select.
topInt32the (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
topInt32The top limit, use -1 to set to unlimited.
membersMemberDeclaration[]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
typeStringThe type of the entity.
membersMemberDeclaration[]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
membersMemberDeclaration[]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
setNameStringThe name of the set to reference.
propertyNameStringThe 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
elementExpressionsExpression[]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
skipInt32The skip value.
takeInt32the 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
expressionExpressionThe expression to sum.
Returns
- AggregationFunctionCall
Returns a new Aggregation Function call that can be used in a select new with.