コード例 #1
0
        private void BuildReturning(Aliaser aliaser, DeleteStatement statement, IEnumerable <SchemaMember> schemas)
        {
            statement.Returning = new ReturningClause(TableDefinition.Temporary());

            foreach (var key in statement.Entity.Key)
            {
                statement.Returning.Table.Field(key);
                statement.Returning.Append(statement.Table.CreateField(key), ReturningClause.ReturningMode.Deleted);
            }

            var super = statement.Entity.GetBaseEntity();

            while (super != null)
            {
                this.BuildInherit(aliaser, statement, super);
                super = super.GetBaseEntity();
            }

            foreach (var schema in schemas)
            {
                if (schema.Token.Property.IsSimplex)
                {
                    continue;
                }

                var     complex = (IDataEntityComplexProperty)schema.Token.Property;
                ISource src     = complex.Entity == statement.Entity ?
                                  statement.Table :
                                  statement.Join(aliaser, statement.Table, complex.Entity);

                foreach (var link in complex.Links)
                {
                    var anchors = link.GetAnchors();

                    if (anchors.Length > 1)
                    {
                        continue;
                    }

                    ISource source = statement.Table;

                    foreach (var anchor in link.GetAnchors())
                    {
                        if (anchor.IsComplex)
                        {
                            source = statement.Join(aliaser, source, (IDataEntityComplexProperty)anchor);
                        }
                        else
                        {
                            //某些导航属性可能与主键相同,表定义的字段定义方法(TableDefinition.Field(...))可避免同名字段的重复定义
                            if (statement.Returning.Table.Field((IDataEntitySimplexProperty)anchor) != null)
                            {
                                statement.Returning.Append(src.CreateField(anchor.Name), ReturningClause.ReturningMode.Deleted);
                            }
                        }
                    }
                }

                this.BuildSlave(aliaser, statement, schema);
            }
        }
コード例 #2
0
 public TableIdentifier(TableDefinition table, string alias = null)
 {
     this.Table = table ?? throw new ArgumentNullException(nameof(table));
     this.Alias = alias;
     this.Name  = table.Name;
 }