public void AddDeployment(Deployment deployment)
        {
            if (deployment == null)
            {
                throw new ArgumentNullException("deployment");
            }

            const string CommandText =
                @"
            INSERT INTO Deployment
            (Created, PipelineId, EnvironmentId)
            VALUES
            (@Created, @PipelineId, @EnvironmentId)

            SET @DeploymentId = @@IDENTITY";
            var deploymentIdParameter =
                new SqlParameter("DeploymentId", SqlDbType.Int) { Direction = ParameterDirection.Output };
            using (DbCommand command = CreateCommand())
            {
                command.CommandText = CommandText;
                ModifyData(
                    command,
                    new SqlParameter("Created", deployment.Created),
                    new SqlParameter("PipelineId", deployment.PipelineId),
                    new SqlParameter("EnvironmentId", deployment.EnvironmentId),
                    deploymentIdParameter);
            }

            deployment.ChangeId((int)deploymentIdParameter.Value);
        }
        public void AddDeployment(Deployment deployment)
        {
            if (deployment == null)
            {
                throw new ArgumentNullException("deployment");
            }

            int newId = 1;
            if (_deployments.Count > 0)
            {
                newId = _deployments.Max(d => d.Id.Value) + 1;
            }

            deployment.ChangeId(newId);
            _deployments.Add(deployment);
        }
        public void AddDeployment(Deployment deployment)
        {
            if (deployment == null)
            {
                throw new ArgumentNullException("deployment");
            }

            const string sql = @"
            INSERT INTO Deployment
            (Created, PipelineId, EnvironmentId)
            VALUES
            (@Created, @PipelineId, @EnvironmentId)

            SET @DeploymentId = Scope_Identity()";
            var param =
                new {deployment.Created, deployment.PipelineId, deployment.EnvironmentId};
            int deploymentId = _connection.ExecuteAndGetGeneratedId(sql,
                                                                    param,
                                                                    "DeploymentId");
            deployment.ChangeId(deploymentId);
        }