当前位置: 首页>>代码示例>>C#>>正文


C# IQueryContext.GetTable方法代码示例

本文整理汇总了C#中IQueryContext.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryContext.GetTable方法的具体用法?C# IQueryContext.GetTable怎么用?C# IQueryContext.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQueryContext的用法示例。


在下文中一共展示了IQueryContext.GetTable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Default

        public static ColumnChecker Default(IQueryContext context, ObjectName tableName)
        {
            var table = context.GetTable(tableName);
            if (table == null)
                throw new InvalidOperationException(String.Format("Table '{0}' not found in the context.", tableName));

            var tableInfo = table.TableInfo;
            var ignoreCase = context.IgnoreIdentifiersCase();

            return new DefaultChecker(tableInfo, ignoreCase);
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:11,代码来源:ColumnChecker.cs

示例2: PrepareStatement

        protected override SqlPreparedStatement PrepareStatement(IExpressionPreparer preparer, IQueryContext context)
        {
            var tableName = context.ResolveTableName(TableName);

            var table = context.GetTable(tableName);
            if (table == null)
                throw new InvalidOperationException();

            if (Values.Any(x => x.OfType<SqlQueryExpression>().Any()))
                throw new InvalidOperationException("Cannot set a value from a query.");

            var columnInfos = new List<ColumnInfo>();
            foreach (var name in ColumnNames) {
                var columnName = ObjectName.Parse(name);
                var colIndex = table.FindColumn(columnName);
                if (colIndex < 0)
                    throw new InvalidOperationException(String.Format("Cannot find column '{0}' in table '{1}'", columnName, table.FullName));

                columnInfos.Add(table.TableInfo[colIndex]);
            }

            var assignments = new List<SqlAssignExpression[]>();

            foreach (var valueSet in Values) {
                var valueAssign = new SqlAssignExpression[valueSet.Length];

                for (int i = 0; i < valueSet.Length; i++) {
                    var columnInfo = columnInfos[i];

                    var value = valueSet[i];
                    if (value != null) {
                        // TODO: Deference columns with a preparer
                    }

                    if (value != null) {
                        var expReturnType = value.ReturnType(context, null);
                        if (!columnInfo.ColumnType.IsComparable(expReturnType))
                            throw new InvalidOperationException();
                    }

                    valueAssign[i] = SqlExpression.Assign(SqlExpression.Reference(columnInfo.FullColumnName), value);
                }

                assignments.Add(valueAssign);
            }

            return new Prepared(tableName, assignments);
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:48,代码来源:InsertValuesStatement.cs

示例3: Evaluate

            public override ITable Evaluate(IQueryContext context)
            {
                if (!context.UserCanAlterTable(TableName))
                    throw new InvalidAccessException(TableName);

                var table = context.GetTable(TableName);
                if (table == null)
                    throw new ObjectNotFoundException(TableName);

                var tableInfo = table.TableInfo;
                var newTableInfo = new TableInfo(tableInfo.TableName);

                var checker = ColumnChecker.Default(context, TableName);

                bool tableAltered = false;
                bool markDropped = false;

                for (int n = 0; n < tableInfo.ColumnCount; ++n) {
                    var column = tableInfo[n];

                    string columnName = column.ColumnName;
                    var columnType = column.ColumnType;
                    var defaultExpression = column.DefaultExpression;

                    if (Action.ActionType == AlterTableActionType.SetDefault &&
                        CheckColumnNamesMatch(context, ((SetDefaultAction) Action).ColumnName, columnName)) {
                        var exp = ((SetDefaultAction) Action).DefaultExpression;
                        exp = checker.CheckExpression(exp);
                        defaultExpression = exp;
                        tableAltered = true;
                    } else if (Action.ActionType == AlterTableActionType.DropDefault &&
                               CheckColumnNamesMatch(context, ((DropDefaultAction) Action).ColumnName, columnName)) {
                        defaultExpression = null;
                        tableAltered = true;
                    } else if (Action.ActionType == AlterTableActionType.DropColumn &&
                               CheckColumnNamesMatch(context, ((DropColumnAction) Action).ColumnName, columnName)) {
                        // Check there are no referential links to this column
                        var refs = context.GetTableImportedForeignKeys(TableName);
                        foreach (var reference in refs) {
                            CheckColumnConstraint(columnName, reference.ForeignColumnNames, reference.ForeignTable, reference.ConstraintName);
                        }

                        // Or from it
                        refs = context.GetTableForeignKeys(TableName);
                        foreach (var reference in refs) {
                            CheckColumnConstraint(columnName, reference.ColumnNames, reference.TableName, reference.ConstraintName);
                        }

                        // Or that it's part of a primary key
                        var primaryKey = context.GetTablePrimaryKey(TableName);
                        if (primaryKey != null)
                            CheckColumnConstraint(columnName, primaryKey.ColumnNames, TableName, primaryKey.ConstraintName);

                        // Or that it's part of a unique set
                        var uniques = context.GetTableUniqueKeys(TableName);
                        foreach (var unique in uniques) {
                            CheckColumnConstraint(columnName, unique.ColumnNames, TableName, unique.ConstraintName);
                        }

                        markDropped = true;
                        tableAltered = true;
                    }

                    var newColumn = new ColumnInfo(columnName, columnType);
                    if (defaultExpression != null)
                        newColumn.DefaultExpression = defaultExpression;

                    newColumn.IndexType = column.IndexType;
                    newColumn.IsNotNull = column.IsNotNull;

                    // If not dropped then add to the new table definition.
                    if (!markDropped) {
                        newTableInfo.AddColumn(newColumn);
                    }
                }

                if (Action.ActionType == AlterTableActionType.AddColumn) {
                    var col = ((AddColumnAction)Action).Column;

                    checker.CheckExpression(col.DefaultExpression);
                    var columnName = col.ColumnName;
                    var columnType = col.ColumnType;

                    // If column name starts with [table_name]. then strip it off
                    columnName = checker.StripTableName(TableName.Name, columnName);
                    if (tableInfo.IndexOfColumn(col.ColumnName) != -1)
                        throw new InvalidOperationException("The column '" + col.ColumnName + "' is already in the table '" + tableInfo.TableName + "'.");

                    var newColumn = new ColumnInfo(columnName, columnType) {
                        IsNotNull = col.IsNotNull,
                        DefaultExpression = col.DefaultExpression
                    };

                    newTableInfo.AddColumn(newColumn);
                    tableAltered = true;
                }

                if (Action.ActionType == AlterTableActionType.DropConstraint) {
                    string constraintName = ((DropConstraintAction)Action).ConstraintName;
                    int dropCount = context.DropConstraint(TableName, constraintName);
//.........这里部分代码省略.........
开发者ID:prepare,项目名称:deveeldb,代码行数:101,代码来源:AlterTableStatement.cs

示例4: Evaluate

 public ITable Evaluate(IQueryContext context)
 {
     var t = context.GetTable(TableName);
     return AliasName != null ? new ReferenceTable(t, AliasName) : t;
 }
开发者ID:prepare,项目名称:deveeldb,代码行数:5,代码来源:FetchTableNode.cs

示例5: Evaluate

 /// <inheritdoc/>
 public virtual ITable Evaluate(IQueryContext context)
 {
     ITable t = context.GetTable(tableName);
     return aliasName != null ? new ReferenceTable((Table)t, aliasName) : t;
 }
开发者ID:kaktusan,项目名称:plsqlparser,代码行数:6,代码来源:FetchTableNode.cs


注:本文中的IQueryContext.GetTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。