/// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public static int Update(MembershipUserEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var command = KandaTableDataGateway._factory.CreateCommand(connection, transaction);

            command.CommandText = @"usp_UpdateMembershipUsers";

            KandaDbDataMapper.MapToParameters(command, entity);

            var result = KandaTableDataGateway._factory.CreateParameter(KandaTableDataGateway.RETURN_VALUE, DbType.Int32, sizeof(int), ParameterDirection.ReturnValue, DBNull.Value);
            command.Parameters.Add(result);

            command.ExecuteNonQuery();

            return (int)result.Value;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public bool Create(MembershipUserEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var error = MembershipUsersGateway.Insert(entity, connection, transaction);

            return (error == KandaTableDataGateway.NO_ERRORS);
        }
        public void DeleteForeighKeyOnMembershipIDFact()
        {
            var connection = default(DbConnection);
            var transaction = default(DbTransaction);

            try
            {
                connection = this._factory.CreateConnection();
                connection.Open();

                transaction = connection.BeginTransaction();

                // Memberships
                var membership = new MembershipEntity() { Name = new Random().Next().ToString(CultureInfo.InvariantCulture), Password = @"password", };
                var memberships = new MembershipsRepository();
                membership.CreatedOn = KandaRepository.GetUtcDateTime(connection, transaction);
                var status = MembershipCreateStatus.ProviderError;
                if (!memberships.Create(membership , connection, transaction, out status)) { Assert.True(!true); }

                // Users
                var user = new UserEntity() { /*ID = @"",*/ FamilyName = @"family name", GivenName = @"given name", AdditionalName = @"additional name", Description = @"description", CreatedOn = membership.CreatedOn, Enabled = true, };
                var users = new UsersRepository();
                if (!users.Create(user, connection, transaction)) { Assert.True(!true); }

                // MembershipUsers
                var entity = new MembershipUserEntity() { MembershipID = membership.ID, UserID = user.ID };
                var repository = new MembershipUsersRepository();
                if (!repository.Create(entity, connection, transaction)) { Assert.True(!true); }

                // 削除
                if (!repository.Delete(new MembershipUsersCriteria() { MembershipID = entity.MembershipID, UserID = entity.UserID, }, connection, transaction)) { Assert.True(!true); }
                if (!memberships.Delete(entity.MembershipID, connection, transaction)) { Assert.True(!true); }
                if (!users.Delete(entity.UserID, connection, transaction)) { Assert.True(!true); }

                Assert.True(true);
            }
            finally
            {
                if (transaction != null) { transaction.Rollback(); }
                if (connection != null) { connection.Close(); }
            }
        }