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


C# IQueryContext.GetTableQueryInfo方法代码示例

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


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

示例1: Create

        public static QueryExpressionFrom Create(IQueryContext context, SqlQueryExpression expression)
        {
            // Get the 'from_clause' from the table expression
            var fromClause = expression.FromClause;
            var ignoreCase = context.IgnoreIdentifiersCase();

            var queryFrom = new QueryExpressionFrom(ignoreCase);
            foreach (var fromTable in fromClause.AllTables) {
                var uniqueKey = fromTable.UniqueKey;
                var alias = fromTable.Alias;

                if (fromTable.IsSubQuery) {
                    // eg. FROM ( SELECT id FROM Part )
                    var subQuery = fromTable.SubQuery;
                    var subQueryFrom = Create(context, subQuery);

                    // The aliased name of the table
                    ObjectName aliasTableName = null;
                    if (alias != null)
                        aliasTableName = new ObjectName(alias);

                    // Add to list of sub-query tables to add to command,
                    queryFrom.AddTable(new FromTableSubQuerySource(ignoreCase, uniqueKey, subQuery, subQueryFrom, aliasTableName));
                } else {
                    // Else must be a standard command table,
                    string name = fromTable.Name;

                    // Resolve to full table name
                    var tableName = context.ResolveTableName(name);

                    if (!context.TableExists(tableName))
                        throw new InvalidOperationException(String.Format("Table '{0}' was not found.", tableName));

                    ObjectName givenName = null;
                    if (alias != null)
                        givenName = new ObjectName(alias);

                    // Get the ITableQueryInfo object for this table name (aliased).
                    ITableQueryInfo tableQueryInfo = context.GetTableQueryInfo(tableName, givenName);

                    queryFrom.AddTable(new FromTableDirectSource(ignoreCase, tableQueryInfo, uniqueKey, givenName, tableName));
                }
            }

            // Set up functions, aliases and exposed variables for this from set,

            foreach (var selectColumn in expression.SelectColumns) {
                // Is this a glob?  (eg. Part.* )
                if (selectColumn.IsGlob) {
                    // Find the columns globbed and add to the 'selectedColumns' result.
                    if (selectColumn.IsAll) {
                        queryFrom.ExposeAllColumns();
                    } else {
                        // Otherwise the glob must be of the form '[table name].*'
                        queryFrom.ExposeColumns(selectColumn.TableName);
                    }
                } else {
                    // Otherwise must be a standard column reference.  Note that at this
                    // time we aren't sure if a column expression is correlated and is
                    // referencing an outer source.  This means we can't verify if the
                    // column expression is valid or not at this point.

                    // If this column is aliased, add it as a function reference to the
                    // select expression

                    string alias = selectColumn.Alias;
                    var v = selectColumn.Expression.AsReferenceName();
                    bool aliasMatchV = (v != null && alias != null &&
                                        queryFrom.CompareStrings(v.Name, alias));
                    if (alias != null && !aliasMatchV) {
                        queryFrom.AddExpression(new ExpressionReference(selectColumn.Expression, alias));
                        queryFrom.ExposeColumn(new ObjectName(alias));
                    } else if (v != null) {
                        var resolved = queryFrom.ResolveReference(v);
                        queryFrom.ExposeColumn(resolved ?? v);
                    } else {
                        string funName = selectColumn.Expression.ToString();
                        queryFrom.AddExpression(new ExpressionReference(selectColumn.Expression, funName));
                        queryFrom.ExposeColumn(new ObjectName(funName));
                    }
                }
            }

            return queryFrom;
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:85,代码来源:QueryExpressionFrom.cs


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