Beispiel #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);
            }
        }
Beispiel #2
0
 public FromClause(ScriptDom.FromClause src) : base(src)
 {
     Copier.CopyList(this.TableReferences, src.TableReferences);
 }
Beispiel #3
0
 public virtual void ExplicitVisit(FromClause fromClause)
 {
 }