Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
 internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
 {
     if (columns.TryGetValue(sourceColumnName, out ColumnTypeMetadata columnTypeX))
     {
         columnType = new SourceColumnType(this, sourceColumnName, columnTypeX.ColumnDbType, columnTypeX.AllowNull);
         return(true);
     }
     else
     {
         columnType = null;
         return(false);
     }
 }
Ejemplo n.º 3
0
        internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
        {
            for (int idx = 0; idx < _cteColumns.Count; idx++)
            {
                Identifier col = _cteColumns[idx];
                if (string.Equals(sourceColumnName, col.Dequote(), StringComparison.OrdinalIgnoreCase))
                {
                    // get the query's output column on this index
                    if (this.query.TryGetQueryOutputColumnAt(batchResolver, idx, out QueryColumnBase outputColumnX))
                    {
                        if (outputColumnX.ColumnDbType.HasValue)
                        {
                            columnType = new SourceColumnType(this, sourceColumnName, outputColumnX.ColumnDbType.Value, outputColumnX.AllowNull.GetValueOrDefault(true));
                            return(true);
                        }
                        else
                        {
                            columnType = new SourceColumnType(this, sourceColumnName);//  DbType.Object;
                            return(true);
                        }
                    }
                    else
                    {
                        columnType = null;
                        return(false);
                    }
                }
            }

            if (this.query.TryGetQueryOutputColumnByName(batchResolver, sourceColumnName, out QueryColumnBase outputColumn))
            {
                if (outputColumn.ColumnDbType.HasValue)
                {
                    columnType = new SourceColumnType(this, sourceColumnName, outputColumn.ColumnDbType.Value, outputColumn.AllowNull.GetValueOrDefault(true));
                    return(true);
                }
                else
                {
                    columnType = new SourceColumnType(this, sourceColumnName);//  DbType.Object;
                    return(true);
                }
            }
            columnType = null;// DbType.Object;
            return(false);
        }
Ejemplo n.º 4
0
 internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
 {
     if (this.query.TryGetQueryOutputColumnByName(batchResolver, sourceColumnName, out QueryColumnBase outputColumn))
     {
         if (outputColumn.ColumnDbType.HasValue)
         {
             columnType = new SourceColumnType(this, sourceColumnName, outputColumn.ColumnDbType.Value, outputColumn.AllowNull.GetValueOrDefault(true));
             return(true);
         }
         else
         {
             columnType = new SourceColumnType(this, sourceColumnName);//  DbType.Object;
             return(true);
         }
     }
     columnType = null;// DbType.Object;
     return(false);
 }
Ejemplo n.º 5
0
        internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
        {
            // KEY: int
            // RANK: int

            if (string.Equals("KEY", sourceColumnName, StringComparison.OrdinalIgnoreCase))
            {
                columnType = new SourceColumnType(this, sourceColumnName, DbType.Int32, true);
                return(true);
            }

            if (string.Equals("RANK", sourceColumnName, StringComparison.OrdinalIgnoreCase))
            {
                columnType = new SourceColumnType(this, sourceColumnName, DbType.Int32, true);
                return(true);
            }

            columnType = null;
            return(false);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
 {
     return(Cte.TryResolveSourceColumnType(batchResolver, sourceColumnName, out columnType));
 }
Ejemplo n.º 9
0
 internal abstract bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType);
Ejemplo n.º 10
0
 internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
 {
     columnType = new SourceColumnType(this, sourceColumnName, variableType, true);
     return(true);
 }
Ejemplo n.º 11
0
 internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
 {
     columnType = null;// DbType.Object;
     return(false);
 }
Ejemplo n.º 12
0
 internal override bool TryResolveSourceColumnType(BatchOutputColumnTypeResolver batchResolver, string sourceColumnName, out SourceColumnType columnType)
 {
     columnType = new SourceColumnType(this, sourceColumnName, constantType, allowNull);
     return(true);
 }