Ejemplo n.º 1
0
        /// <summary>Inserts a StylesheetType record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="stylesheetTypeCode">The value for the StylesheetTypeCode column.</param>
        /// <param name="name">The value for the Name column.</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        public static void Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int stylesheetTypeCode, object name, object description, object externalId0, object externalId1)
        {
            // Accessor for the StylesheetType Table.
            ServerDataModel.StylesheetTypeDataTable stylesheetTypeTable = ServerDataModel.StylesheetType;
            // Apply Defaults
            if ((name == null))
            {
                name = System.DBNull.Value;
            }
            if ((description == null))
            {
                description = System.DBNull.Value;
            }
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            if ((externalId1 == null))
            {
                externalId1 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.StylesheetTypeRow stylesheetTypeRow = stylesheetTypeTable.NewStylesheetTypeRow();
            stylesheetTypeRow[stylesheetTypeTable.RowVersionColumn]         = rowVersion;
            stylesheetTypeRow[stylesheetTypeTable.StylesheetTypeCodeColumn] = stylesheetTypeCode;
            stylesheetTypeRow[stylesheetTypeTable.NameColumn]        = name;
            stylesheetTypeRow[stylesheetTypeTable.DescriptionColumn] = description;
            stylesheetTypeRow[stylesheetTypeTable.ExternalId0Column] = externalId0;
            stylesheetTypeRow[stylesheetTypeTable.ExternalId1Column] = externalId1;
            stylesheetTypeTable.AddStylesheetTypeRow(stylesheetTypeRow);
            adoTransaction.DataRows.Add(stylesheetTypeRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand("insert \"StylesheetType\" (\"rowVersion\",\"StylesheetTypeCode\",\"Name\",\"Description\",\"" +
                                                   "ExternalId0\",\"ExternalId1\") values (@rowVersion,@stylesheetTypeCode,@name,@descr" +
                                                   "iption,@externalId0,@externalId1)");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@stylesheetTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stylesheetTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@name", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, name));
            sqlCommand.Parameters.Add(new SqlParameter("@description", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, description));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId1));
            sqlCommand.ExecuteNonQuery();
        }