Пример #1
0
        private DmlfDelete CompileDelete()
        {
            var res = new DmlfDelete();
            res.DeleteTarget = new DmlfSource { Alias = "target" };
            res.SingleFrom.Source = new DmlfSource
            {
                Alias = "target",
                TableOrView = TargetTableSqlName,
                LinkedInfo = TargetLinkedInfo,
            };
            var existSelect = new DmlfSelect();
            res.AddAndCondition(new DmlfNotExistCondition
            {
                Select = existSelect,
            });
            existSelect.SelectAll = true;
            existSelect.From.Add(SourceJoinModel.SourceToRefsJoin);
            CreateKeyCondition(existSelect, "target");
            CreateRestrictionCondition(res, "target", false);
            CreateLifetimeConditions(res, "target");
            CreateReferenceRestrictionsCodition(res, "target");

            CreateFilterConditions(existSelect);
            return res;
        }
Пример #2
0
        public void GetCommands(DmlfBatch res, DatabaseInfo db, ChangeSetModel model, bool allowCascade = true)
        {
            if (allowCascade && (DeleteReferencesCascade || model.DeleteReferencesCascade))
            {
                var refs = GenerateCascadeDeletions(db);
                foreach (var item in refs)
                {
                    item.GetCommands(res, db, model, false);
                }
            }

            if (model.DeleteReferencesCascade && model.DeleteSkipList != null && model.DeleteSkipList.Contains(TargetTable)) return;
            var cmd = new DmlfDelete();
            cmd.DeleteTarget = new DmlfSource
            {
                TableOrView = TargetTable,
                LinkedInfo = LinkedInfo,
                Alias = "basetbl",
            };
            cmd.From.Add(new DmlfFromItem
            {
                Source = cmd.DeleteTarget,
            });
            if (!GetConditions(cmd, this, Conditions, db)) return;
            res.Commands.Add(cmd);
        }
Пример #3
0
        public void GetDeleteCommands(DmlfBatch res, DatabaseInfo db, ChangeSetModel model)
        {
            var table = db.FindTable(TargetTable);
            if (table == null) return;

            if (IsDuplicatingIdentity(db, model))
            {
                var del = new DmlfDelete();
                del.DeleteTarget = new DmlfSource
                    {
                        TableOrView = table.FullName,
                        Alias = "basetbl",
                    };
                del.SingleFrom = new DmlfFromItem
                    {
                        Source = del.DeleteTarget
                    };
                GetConditions(del, this, Conditions, db);

                res.Commands.Add(del);
            }
        }