首页新闻找找看学习计划

关于UnitOfWork的commit方法的小问题

0
悬赏园豆:5 [已关闭问题] 关闭于 2017-08-29 18:00
        public void RegisterAdd(IAggregateRoot entity,IUnitOfWorkRepository unitOfWorkRepo)
        {
            if(!addedEntities.ContainsKey(entity))
            {
                addedEntities.Add(entity,unitOfWorkRepo);
            }
        }

        public void RegisterRemoved(IAggregateRoot entity,IUnitOfWorkRepository unitOfWorkRepo)
        {
            if(!deletedEntities.ContainsKey(entity))
            {
                deletedEntities.Add(entity,unitOfWorkRepo);
            }
        }

        public void Commit()
        {
            using (TransactionScope scope =new TransactionScope())
            {

                this.addedEntities.Keys.ToList().ForEach(q=>
                {
                    this.addedEntities[q].PersistCreationOf(q);

                    //疑问1:假如这边PersistCreationOf用的 ado.net执行完了 创建,这边非sql级别的 事物还可以回滚吗?
                });

                this.changedEntities.Keys.ToList().ForEach(q =>
                {
                    this.changedEntities[q].PersistUpdateOf(q);
                });

                this.deletedEntities.Keys.ToList().ForEach(q =>
                {
                    this.deletedEntities[q].PersistDeletionOf(q);
                });

            }
        }
    }

//疑问1:假如这边PersistCreationOf用的 ado.net执行完了 创建,这边非sql级别的 事物还可以回滚吗?

王庆东mas的主页 王庆东mas | 初学一级 | 园豆:4
提问于:2017-07-06 00:17
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册