Esempio n. 1
0
        /// <summary>
        /// WHERE句 にコンストラクタで指定された条件式を追加する。
        /// </summary>
        /// <param name="node">WHERE句</param>
        public override void ExplicitVisit(Microsoft.SqlServer.TransactSql.ScriptDom.FromClause node)
        {
            try
            {
                var tableReference = FindTableReference.Compile().Invoke(node);
                if (tableReference != null && QualifiedJoinType.HasValue)
                {
                    tableReference = new QualifiedJoin()
                    {
                        QualifiedJoinType    = QualifiedJoinType.Value,
                        FirstTableReference  = tableReference,
                        SecondTableReference = TableReference,
                        JoinHint             = JoinHint.Value,
                        SearchCondition      = BooleanExpression,
                    };
                }
                else if (tableReference != null && UnqualifiedJoinType.HasValue)
                {
                    tableReference = new UnqualifiedJoin()
                    {
                        UnqualifiedJoinType  = UnqualifiedJoinType.Value,
                        FirstTableReference  = tableReference,
                        SecondTableReference = TableReference,
                    };
                }
                else
                {
                    tableReference = TableReference;
                }

                if (FindTableReference.Body is MemberExpression member)
                {
                    var param = Expression.Parameter(typeof(TableReference), "value");
                    var set   = Expression.Lambda <Action <Microsoft.SqlServer.TransactSql.ScriptDom.FromClause, TableReference> >(
                        Expression.Assign(member, param), FindTableReference.Parameters[0], param);
                    set.Compile().Invoke(node, tableReference);
                }
                else
                {
                    var methodCall = ((MethodCallExpression)FindTableReference.Body).Object;
                    var param      = Expression.Parameter(typeof(TableReference), "value");
                    var set        = Expression.Lambda <Action <Microsoft.SqlServer.TransactSql.ScriptDom.FromClause, TableReference> >(
                        Expression.Assign(Expression.MakeIndex(methodCall, typeof(IList <TableReference>).GetProperty("Item"), new List <Expression>()
                    {
                        ((IArgumentProvider)FindTableReference.Body).GetArgument(0)
                    }), param), FindTableReference.Parameters[0], param);
                    set.Compile().Invoke(node, tableReference);
                }
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("指定された結合条件は追加できません。", e);
            }
        }
Esempio n. 2
0
        private void ProcessTableReference(TableReference TableRef)
        {
            string Type = GetFragmentType(TableRef);

            switch (Type)
            {
            case "FullTextTableReference":
                break;

            case "NamedTableReference":
                var    NamedTableRef = (NamedTableReference)TableRef;
                var    Naming        = NamedTableRef.SchemaObject;
                string ObjectName    = (Naming.DatabaseIdentifier == null ? this.databaseName : Naming.DatabaseIdentifier.Value) + "." +
                                       (Naming.SchemaIdentifier == null ? this.schemaName : Naming.SchemaIdentifier.Value) + "." +
                                       (Naming.BaseIdentifier == null ? "" : Naming.BaseIdentifier.Value);
                addSourcetoCurrentObject(ObjectName);

                break;

            case "QueryDerivedTable":
                QueryDerivedTable qdt = (QueryDerivedTable)TableRef;
                ProcessQueryExpression(qdt.QueryExpression);
                break;

            case "QualifiedJoin":
                QualifiedJoin qj = (QualifiedJoin)TableRef;
                ProcessTableReference(qj.FirstTableReference);
                ProcessTableReference(qj.SecondTableReference);
                break;

            case "UnqualifiedJoin":
                UnqualifiedJoin uqj = (UnqualifiedJoin)TableRef;
                ProcessTableReference(uqj.FirstTableReference);
                ProcessTableReference(uqj.SecondTableReference);
                break;

            case "SchemaObjectFunctionTableReference":
                SchemaObjectFunctionTableReference ftr = (SchemaObjectFunctionTableReference)TableRef;
                break;

            case "PivotedTableReference":
                PivotedTableReference pvt = (PivotedTableReference)TableRef;
                ProcessTableReference(pvt.TableReference);
                break;

            default:
                break;
            }
        }
Esempio n. 3
0
        protected override object InternalVisit(UnqualifiedJoin node)
        {
            var first  = Visit <IResultTable>(node.FirstTableReference);
            var second = Visit <IResultTable>(node.SecondTableReference);

            switch (node.UnqualifiedJoinType)
            {
            case UnqualifiedJoinType.CrossJoin:
                return(new CrossJoinedTable(first, second));

            case UnqualifiedJoinType.CrossApply:
            case UnqualifiedJoinType.OuterApply:
            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 4
0
 public override void Visit(UnqualifiedJoin node) { this.action(node); }
Esempio n. 5
0
 public override void ExplicitVisit(UnqualifiedJoin node)
 {
     CommandStatistics.JoinsCount++;
     base.ExplicitVisit(node);
 }
Esempio n. 6
0
 private IList <TableIdentifier> ProcessJoin(UnqualifiedJoin joinRef, SqlAction action)
 {
     return(ProcessTableReferences(new List <TableReference> {
         joinRef.FirstTableReference, joinRef.SecondTableReference
     }, action));
 }
 public override void ExplicitVisit(UnqualifiedJoin fragment)
 {
     _fragments.Add(fragment);
 }
Esempio n. 8
0
 public override void ExplicitVisit(UnqualifiedJoin node)
 {
     CommandStatistics.JoinsCount++;
     base.ExplicitVisit(node);
 }
Esempio n. 9
0
 public override void ExplicitVisit(UnqualifiedJoin node)
 {
     base.ExplicitVisit(node); // ? CROSS APPLY
 }