コード例 #1
0
        private IEnumerable <JoinClause> Join(Aliaser aliaser, DeleteStatement statement, TableIdentifier table, string fullPath = null)
        {
            if (table == null || table.Entity == null)
            {
                yield break;
            }

            var super = table.Entity.GetBaseEntity();

            while (super != null)
            {
                var clause = JoinClause.Create(table,
                                               fullPath,
                                               name => statement.From.TryGet(name, out var join) ? (JoinClause)join : null,
                                               entity => new TableIdentifier(entity, aliaser.Generate()));

                if (!statement.From.Contains(clause))
                {
                    statement.From.Add(clause);
                    statement.Tables.Add((TableIdentifier)clause.Target);
                }

                super = super.GetBaseEntity();

                yield return(clause);
            }
        }
コード例 #2
0
ファイル: Statement.cs プロジェクト: Zongsoft/Framework
        /// <inheritdoc />
        public JoinClause Join(Aliaser aliaser, ISource source, IDataEntity target, string fullPath = null)
        {
            var clause = JoinClause.Create(source,
                                           target,
                                           fullPath,
                                           name => this.From.TryGet(name, out var join) ? (JoinClause)join : null,
                                           entity => new TableIdentifier(entity, aliaser.Generate()));

            if (!this.From.Contains(clause))
            {
                this.From.Add(clause);
            }

            return(clause);
        }
コード例 #3
0
ファイル: Statement.cs プロジェクト: Zongsoft/Framework
        /// <inheritdoc />
        public JoinClause Join(Aliaser aliaser, ISource source, IDataEntityComplexProperty complex, string fullPath = null)
        {
            var joins = JoinClause.Create(source,
                                          complex,
                                          fullPath,
                                          name => this.From.TryGet(name, out var join) ? (JoinClause)join : null,
                                          entity => new TableIdentifier(entity, aliaser.Generate()));

            JoinClause last = null;

            foreach (var join in joins)
            {
                if (!this.From.Contains(join))
                {
                    this.From.Add(join);
                }

                last = join;
            }

            //返回最后一个Join子句
            return(last);
        }