コード例 #1
0
        public override void PersistUpdateOf(IAggregateRoot entity)
        {
            var    application = (Application)entity;
            string sql         = "update [application] set [appId] = @appId,[appName] = @appName,[lastUpdateTime] = @lastUpdateTime,[isRemoved] = @isRemoved,[status] = @status where token=@token and appId=@appId";
            var    conn        = SqlConnectionContextFactory.GetSqlConnection();

            conn.Execute(sql,
                         new
            {
                appId          = application.AppId,
                appName        = application.AppName,
                lastUpdateTime = application.LastUpdateTime,
                isRemoved      = application.IsRemoved,
                status         = application.Status,
                token          = application.Token
            },
                         DbTranContextFactory.GetSqlTransaction()
                         );
        }
コード例 #2
0
        public override void PersistCreationOf(IAggregateRoot entity)
        {
            var    application = (Application)entity;
            string sql         = "insert into [application]([token],[appId],[appName],[createTime],[lastUpdateTime],[isRemoved],[status]) " +
                                 "values(@token, @appId, @appName, @createTime, @lastUpdateTime, @isRemoved, @status)";
            var conn = SqlConnectionContextFactory.GetSqlConnection();

            conn.Execute(sql,
                         new
            {
                token          = application.Token,
                appId          = application.AppId,
                appName        = application.AppName,
                createTime     = application.CreateTime,
                lastUpdateTime = application.LastUpdateTime,
                isRemoved      = application.IsRemoved,
                status         = application.Status
            },
                         transaction: DbTranContextFactory.GetSqlTransaction()
                         );
        }
コード例 #3
0
        /// <summary>
        /// 所有命令必须通过Commit才能提交
        /// </summary>
        public void Commit()
        {
            using (var conn = SqlConnectionContextFactory.GetSqlConnection())
                using (var dbtran = DbTranContextFactory.GetSqlTransaction())
                {
                    foreach (IAggregateRoot entity in this.Amended.Keys)
                    {
                        this.Amended[entity].PersistUpdateOf(entity);
                    }

                    foreach (IAggregateRoot entity in this.New.Keys)
                    {
                        this.New[entity].PersistCreationOf(entity);
                    }

                    foreach (IAggregateRoot entity in this.Removed.Keys)
                    {
                        this.Removed[entity].PersistDeletionOf(entity);
                    }

                    dbtran.Commit();
                    CleanContainer();
                }
        }
コード例 #4
0
        public override void PersistDeletionOf(IAggregateRoot entity)
        {
            var    application = (Application)entity;
            string sql         = "update [application] set isremoved=1 where token=@token and appId = @appId";
            var    conn        = SqlConnectionContextFactory.GetSqlConnection();

            conn.Execute(sql, new { token = application.Token, appId = application.AppId }, DbTranContextFactory.GetSqlTransaction());
        }