示例#1
0
        internal IColumnSourceMetadata TryGetTableVariable(string variableName)
        {
            if (cache_table_variables.TryGetValue(variableName, out TableVariableMetadata source_metadata))
            {
                return(source_metadata);
            }
            TableVariableDeclarionVisitor vstor = new TableVariableDeclarionVisitor(variableName);

            BodyFragment.Accept(vstor);
            if (vstor.variableDefinition != null)
            {
                source_metadata = new TableVariableMetadata(vstor.variableDefinition);
                cache_table_variables.Add(variableName, source_metadata);
                return(source_metadata);
            }

            if (vstor.VariableDataType != null)
            {
                IColumnSourceMetadata udt_metadata = SchemaMetadata.TryGetUserDefinedTableTypeMetadata(vstor.VariableDataType.Name.SchemaIdentifier.Dequote(), vstor.VariableDataType.Name.BaseIdentifier.Dequote());
                return(udt_metadata);
            }
            var prm = parameters.TryGetParameterType(vstor.VariableName);

            if (prm != null && prm.IsUserDefinedTableType)
            {
                IColumnSourceMetadata udt = SchemaMetadata.TryGetUserDefinedTableTypeMetadata(prm.UserDefinedTableTypeSchema, prm.UserDefinedTableTypeName);
                if (udt != null)
                {
                    return(udt);
                }
            }
            //BodyFragment.Accept(new DumpFragmentVisitor(true));
            throw new NotImplementedException(variableName);
        }
示例#2
0
        internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnDbType)
        {
            if (string.IsNullOrEmpty(sourceColumnName))
            {
                throw new ArgumentNullException(nameof(sourceColumnName));
            }

            if (resolved_table == null)
            {
                resolved_table = batchResolver.SchemaMetadata.TryGetColumnSourceMetadata(SchemaName, TableName);
                if (resolved_table == null)
                {
                    // table not exists???
                    throw new NotImplementedException(Key + "." + sourceColumnName);
                }
            }

            ColumnTypeMetadata sourceColumnType = resolved_table.TryGetColumnTypeByName(sourceColumnName);

            if (sourceColumnType != null)
            {
                columnDbType = new SourceColumnType(this, sourceColumnName, sourceColumnType.ColumnDbType, sourceColumnType.AllowNull);
                return(true);
            }
            else
            {
                //throw new NotImplementedException(Key + "." + sourceColumnName + "   Table: [" + SchemaName + "].[" + TableName + "]");
                columnDbType = null;// DbType.Object; // column 'personid' without alias => source traversion
                return(false);
            }
        }
示例#3
0
        //private QueryColumnBase override_TryResolveSelectedColumn(BatchOutputColumnTypeResolver batchResolver, string outputColumnName, string sourceColumnName)
        //{
        //    if (resolved_source_metadata == null)
        //    {
        //        resolved_source_metadata = batchResolver.TryGetTableVariable(VarTableRef.Variable.Name);
        //        if (resolved_source_metadata == null)
        //        {
        //            throw new NotImplementedException(VarTableRef.WhatIsThis());
        //        }
        //    }

        //    return base.AddResolveOutputdColumn(new QueryColumnE(this, outputColumnName, sourceColumnName, columnDbType.Value));

        //}

        internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
        {
            if (resolved_source_metadata == null)
            {
                resolved_source_metadata = batchResolver.TryGetTableVariable(VarTableRef.Variable.Name);
                if (resolved_source_metadata == null)
                {
                    throw new NotImplementedException(VarTableRef.WhatIsThis());
                }
            }

            ColumnTypeMetadata columnDbType = resolved_source_metadata.TryGetColumnTypeByName(sourceColumnName);

            if (columnDbType != null)
            {
                columnType = new SourceColumnType(this, sourceColumnName, columnDbType.ColumnDbType, columnDbType.AllowNull);
                return(true);
            }

            columnType = null;// DbType.Object;
            return(false);
        }
示例#4
0
        //internal QueryColumnBase override_TryResolveSelectedColumn(BatchOutputColumnTypeResolver batchResolver, string outputColumnName, string sourceColumnName)
        //{
        //    if (resolved_source_metadata == null)
        //    {
        //        resolved_source_metadata = batchResolver.SchemaMetadata.TryGetFunctionTableMetadata(SchemaName, FunctionName);
        //        if (resolved_source_metadata == null)
        //        {
        //            throw new NotImplementedException(SchemaName + "." + FunctionName + "  => " + outputColumnName);
        //        }
        //    }

        //    DbType? columnDbType = resolved_source_metadata.TryGetColumnTypeByName(sourceColumnName);
        //    if (columnDbType == null)
        //    {
        //        return null;
        //    }

        //    string outputColumnNameSafe = outputColumnName ?? sourceColumnName;

        //    return base.AddResolveOutputdColumn(new QueryColumnE(this, outputColumnNameSafe, sourceColumnName, columnDbType.Value));
        //}

        internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
        {
            if (resolved_source_metadata == null)
            {
                resolved_source_metadata = batchResolver.SchemaMetadata.TryGetFunctionTableMetadata(SchemaName, FunctionName);
                if (resolved_source_metadata == null)
                {
                    throw new NotImplementedException(SchemaName + "." + FunctionName + "  : " + sourceColumnName);
                }
            }


            ColumnTypeMetadata columnDbType = resolved_source_metadata.TryGetColumnTypeByName(sourceColumnName);

            if (columnDbType != null)
            {
                columnType = new SourceColumnType(this, sourceColumnName, columnDbType.ColumnDbType, columnDbType.AllowNull);
                return(true);
            }

            columnType = null; // DbType.Object;
            return(false);
        }