public static ValueNode AliasedCol <TTable>(AggregateType type, ValueNode parameter, string alias) { return(ValueNode.NewNamedColumn( new AliasedColumnNode( ValueNode.NewAggregate(new Tuple <AggregateType, ValueNode>(type, parameter)), alias))); }
public static OrderByClauseNode OrderClause(ValueNode col, Direction direction, NullsOrdering nullsOrdering = null) { return(new OrderByClauseNode( direction, nullsOrdering ?? NullsOrdering.NullsUndefined, col)); }
public static JoinClauseNode Join <TSource, TTarget>(JoinType type, ValueNode joinExpr) { return(new JoinClauseNode( new FSharpList <ITableIdentifier>(new TableIdentifier <TSource>(), FSharpList <ITableIdentifier> .Empty), new TableIdentifier <TTarget>(), type, joinExpr.ToOption())); }
public static ValueNode AliasedCol( string alias, AggregateType type, ValueNode aggregateParameter, IEnumerable <ValueNode> partitionBy = null, IEnumerable <OrderByClauseNode> orderBy = null) { return(ValueNode.NewNamedColumn( new AliasedColumnNode( WinCol(type, aggregateParameter, partitionBy, orderBy), alias))); }
public static JoinClauseNode Join <TSource1, TSource2, TTarget>( ITableIdentifier <TSource1> source1, ITableIdentifier <TSource2> source2, ITableIdentifier <TTarget> target, JoinType type, ValueNode joinExpr) { return(new JoinClauseNode( ListModule.OfArray(new ITableIdentifier[] { source1, source2 }), target, type, joinExpr.ToOption())); }
public static ValueNode WinCol( AggregateType type, ValueNode aggregateParameter, IEnumerable <ValueNode> partitionBy = null, IEnumerable <OrderByClauseNode> orderBy = null) { return(ValueNode.NewWindowedColumn( new Tuple <Tuple <AggregateType, ValueNode>, AST.WindowNode>( new Tuple <AggregateType, ValueNode>(type, aggregateParameter), new AST.WindowNode( partitionBy == null ? ListModule.Empty <ValueNode>() : ListModule.OfSeq(partitionBy), orderBy == null ? ListModule.Empty <OrderByClauseNode>() : ListModule.OfSeq(orderBy))))); }
public void ItCanVisitAMultipleColumnSelector() { Expression <Func <Person, object> > func = (Person p) => new { p.Age, p.Name }; var tableRef = Types.TableReferenceFromType <Person>(); var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), new[] { tableRef }.ToContext() ); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.Col <Person>("Age"), S.Col <Person>("Name") })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public static ValueNode SubExp( SelectValuesExpressionNode select, FromExpressionNode from, WhereExpressionNode where = null, GroupByExpressionNode groupBy = null, OrderByExpressionNode orderBy = null) { return(ValueNode.NewSubExpression( PlainSelectExpression.NewPlain( new SelectExpressionToken( select, from, where.ToOption(), groupBy.ToOption(), orderBy.ToOption())))); }
public static ValueNode SubExp( SelectValuesExpressionNode select, FromExpressionNode from, WhereExpressionNode where = null, GroupByExpressionNode groupBy = null, OrderByExpressionNode orderBy = null, LimitOffsetNode limitOffset = null) { return(ValueNode.NewSubExpression( PlainSelectExpression.NewPlain( new SelectExpressionToken( select, from, where.ToOption(), groupBy.ToOption(), orderBy.ToOption(), limitOffset ?? new LimitOffsetNode(FSharpOption <int> .None, FSharpOption <int> .None))))); }
public void ItShouldBeAbleToGenerateAliasesForBinaryExpressions() { Expression <Func <Person, object> > func = (Person p) => new { AgePlusTen = p.Age + 10 }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.AliasedCol(S.BinExp(S.Col <Person>("Age"), BinaryOperation.Add, S.Const(10)), "AgePlusTen"), })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public void ItShouldNotGenerateAliasColumnsForColumnsBeingAliasedToItsOrdinaryName() { Expression <Func <Person, object> > func = (Person p) => new { Name = p.Name, Age = p.Age }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.Col <Person>("Name"), S.Col <Person>("Age"), })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public void ItShouldBeAbleToGenerateAliasesForConstants() { Expression <Func <Person, object> > func = (Person p) => new { FavoriteNumber = 42 }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.AliasedCol(S.Const(42), "FavoriteNumber"), })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public void ItShouldBeAbleToGenerateAliasedColumnTokens() { Expression <Func <Person, object> > func = (Person p) => new { p.Name, AgeOfPerson = p.Age, Count = Sql.Count() }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.Col <Person>("Name"), S.AliasedCol <Person>("Age", "AgeOfPerson"), S.AliasedCol <Person>(AST.AggregateType.Count, S.Null(), "Count") })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public static ValueNode AliasedCol(ValueNode node, string alias) { return(ValueNode.NewNamedColumn(new AliasedColumnNode(node, alias))); }
public static ValueNode Star <TTable>() { return(ValueNode.NewStarColumn(Types.TableReferenceFromType <TTable>())); }
public static ValueNode Col(ITableReference r, string colDef) { return(ValueNode.NewColumn(new Tuple <string, Type, ITableReference>(colDef, FigureOutTypeFor(colDef, r), r))); }
public static ValueNode Col <TTable>(TableReferenceCreator <TTable> c, string colDef) { var tref = c.ToTableReference().Reference; return(ValueNode.NewColumn(new Tuple <string, Type, ITableReference>(colDef, FigureOutTypeFor(colDef, tref), tref))); }
public static ValueNode Col <TTable>(ITableIdentifier <TTable> r, string columnDef) { return(ValueNode.NewColumn(new Tuple <string, Type, ITableReference>(columnDef, FigureOutTypeFor(columnDef, r.Reference), r.Reference))); }
public static UpdateSetToken Ust <TTableType>(string colDef, ValueNode node) { return(CreateUpdateSetToken <TTableType>(colDef, node)); }
public static WhereExpressionNode Where(ValueNode start, params WhereClauseNode[] additionalClauses) { return (new WhereExpressionNode(start, ListModule.OfArray(additionalClauses))); }
public static ValueNode Aggregate(AggregateType type, ValueNode parameter) { return(ValueNode.NewAggregate(new Tuple <AggregateType, ValueNode>(type, parameter))); }
public static ValueNode AliasedCol <TTable>(string colDef, string alias) { var tref = Types.TableReferenceFromType <TTable>(); return(AliasedCol(ValueNode.NewColumn(new Tuple <string, Type, ITableReference>(colDef, FigureOutTypeFor(colDef, tref), tref)), alias)); }
public static ValueNode BinExp(ValueNode lhs, BinaryOperation op, ValueNode rhs) { return(ValueNode.NewBinaryExpression(new BinaryExpressionNode(lhs, op, rhs))); }
public static ValueNode Func(FunctionType type, params ValueNode[] arguments) { return(ValueNode.NewFunctionCall( new Tuple <FunctionType, FSharpList <ValueNode> >(type, ListModule.OfArray(arguments)))); }
public static ValueNode Const(object constant) { return(ValueNode.NewConstant(constant.ToString())); }
public static WhereClauseNode Or(ValueNode stream) { return(new WhereClauseNode(ExpressionCombinatorType.Or, stream)); }
private static UpdateSetToken CreateUpdateSetToken <TTableType>(string colDef, ValueNode stream) { var tref = Types.TableReferenceFromType <TTableType>(); return(new UpdateSetToken(new Tuple <string, Type, ITableReference>(colDef, FigureOutTypeFor(colDef, tref), tref), stream)); }
public static ValueNode Col <TTableType>(string columnDef) { var tref = Types.TableReferenceFromType <TTableType>(); return(ValueNode.NewColumn(new Tuple <string, Type, ITableReference>(columnDef, FigureOutTypeFor(columnDef, tref), tref))); }
public static ValueNode Param(string paramName) { return(ValueNode.NewParameter(paramName)); }