Example #1
0
 public static SelectStatement SelectC(this ITableExpression table, IEnumerable <string> customers)
 {
     return(SelectVarCustomer(table, customers));
 }
 private void setRootTable(LogicalTable rootTable)
 {
     string alias = createTableAlias(rootTable);
     LogicalQueryTable queryTable = new LogicalQueryTable() {Table = rootTable, Alias = alias};
     PhysicalQueryTable physicalQueryTable = new PhysicalQueryTable() {Table = rootTable.PartOfTable, Alias = alias};
     this.logicalTables.Add (queryTable);
     this.physicalTables.Add (physicalQueryTable);
     this.fromSource = physicalQueryTable.ToTableReference();
     this.lastTableAdded = queryTable;
 }
        private void attachTable(LogicalQueryTable source, LogicalTable joinWith)
        {
            // check if join can be performed, if not then exception is thrown
            validateAttachArguments(source, joinWith);

            // join tables
            LogicalQueryTable target = new LogicalQueryTable() {Table = joinWith};

            // if the join table is in fact a part of another physical table already included in source logical table
            // then dont join them
            // always join tables if the target table is of entity type
            if (!isJoinRequired (source, target)) {
                target.Alias = source.Alias;
            } else {
                string alias = createTableAlias(joinWith);
                target.Alias = alias;

                PhysicalQueryTable physicalQueryTable = new PhysicalQueryTable() {Table = joinWith.PartOfTable, Alias = alias};
                this.physicalTables.Add (physicalQueryTable);

                this.fromSource = createNewJoin (this.fromSource, source, target);
            }

            this.logicalTables.Add (target);
            this.lastTableAdded = target;
        }
Example #4
0
 public static InsertStatement InsertP(this ITableExpression table, params IColumnExpression[] columns)
 {
     return(InsertVarParam(table, columns));
 }
        private ITableExpression createNewJoin(ITableExpression oldJoin, LogicalQueryTable sourceTable, LogicalQueryTable targetTable)
        {
            LogicalQueryTable relationTable = (sourceTable.Table.TableType == LogicalTableType.JOIN ? sourceTable : targetTable);
            LogicalQueryTable entityTable = (sourceTable.Table.TableType == LogicalTableType.ENTITY ? sourceTable : targetTable);

            TableColumn primaryKey = entityTable.Table.GetPrimaryKey();
            TableColumn foreignKey = relationTable.Table.GetForeignKey(primaryKey);

            ILogicalCondition on = Logical.Equal(Expression.Column(entityTable.Alias, primaryKey.Name), Expression.Column (relationTable.Alias, foreignKey.Name));

            return From.Left (oldJoin, targetTable.ToTableReference(), on);
        }
Example #6
0
 public static ISelectStatement J(this ISelectStatement select, ITableExpression table, IFilterExpression on)
 {
     return(Join(select, table, on));
 }
Example #7
0
 public static JoinedTables Left(ITableExpression table, ITableExpression withTable, ILogicalCondition on)
 {
     return new JoinedTables() {Table = table, JoinedWith = withTable, On = on, JoinType = JoinType.LEFTJOIN};
 }
Example #8
0
 public static IInsertStatement Insert(ITableExpression table = null)
 {
     return(new InsertStatement(table));
 }
Example #9
0
 public static IDeleteStatement Delete(ITableExpression table = null)
 {
     return(new DeleteStatement(table));
 }
Example #10
0
 public static InsertStatement InsertVarParam(this ITableExpression table, params ColumnExpression[] columns)
 {
     return(InsertVarParam(table, columns.AsEnumerable()));
 }
Example #11
0
 public static IInsertStatement Into(this IInsertStatement insert, ITableExpression table)
 {
     insert.Table = table;
     return(insert);
 }
Example #12
0
        public static InsertStatement InsertVarParam(this ITableExpression table, IEnumerable <IColumnExpression> columns)
        {
            var _params = columns.Select(col => col.ToParam());

            return(new InsertStatement(table, columns.ToArray(), _params.ToArray()));
        }
Example #13
0
 public static InsertStatement Insert(this ITableExpression table, IEnumerable <IColumnExpression> columns)
 {
     return(new InsertStatement(table, columns.ToArray(), new IValueExpression[columns.Count()]));
 }
Example #14
0
 public static InsertStatement Insert(this ITableExpression table)
 {
     return(new InsertStatement(table));
 }
Example #15
0
 public static SelectStatement SelectC(this ITableExpression table, params string[] customers)
 {
     return(SelectVarCustomer(table, customers));
 }
Example #16
0
 public static IUpdateStatement Update(ITableExpression table)
 {
     return(new UpdateStatement(table));
 }
Example #17
0
 public static ISelectStatement J(this ISelectStatement select, ITableExpression table, IFilterExpression on, IJoinOperator joinOperator)
 {
     return(Join(select, table, on, joinOperator));
 }
Example #18
0
 public static DeleteStatement Delete(this ITableExpression table)
 {
     return(new DeleteStatement(table, null));
 }
Example #19
0
 public static JoinedTables Inner(ITableExpression table, ITableExpression withTable, ILogicalCondition on, string alias)
 {
     return new JoinedTables() {Table = table, JoinedWith = withTable, On = on, Alias = alias, JoinType = JoinType.INNERJOIN};
 }
Example #20
0
 public static IDeleteStatement From(this IDeleteStatement delete, ITableExpression table)
 {
     delete.Table = table;
     return(delete);
 }
Example #21
0
 public static JoinedTables Cross(ITableExpression table, ITableExpression withTable, string alias)
 {
     return new JoinedTables() {Table = table, JoinedWith = withTable, Alias = alias, JoinType = JoinType.CROSSJOIN};
 }
Example #22
0
 public static InsertStatement InsertP(this ITableExpression table, IEnumerable <IColumnExpression> columns)
 {
     return(InsertVarParam(table, columns));
 }