/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="aspnet_ApplicationsRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="aspnet_ApplicationsRow"/> object.</returns> protected virtual aspnet_ApplicationsRow MapRow(DataRow row) { aspnet_ApplicationsRow mappedObject = new aspnet_ApplicationsRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "ApplicationName" dataColumn = dataTable.Columns["ApplicationName"]; if (!row.IsNull(dataColumn)) { mappedObject.ApplicationName = (string)row[dataColumn]; } // Column "LoweredApplicationName" dataColumn = dataTable.Columns["LoweredApplicationName"]; if (!row.IsNull(dataColumn)) { mappedObject.LoweredApplicationName = (string)row[dataColumn]; } // Column "ApplicationId" dataColumn = dataTable.Columns["ApplicationId"]; if (!row.IsNull(dataColumn)) { mappedObject.ApplicationId = (System.Guid)row[dataColumn]; } // Column "Description" dataColumn = dataTable.Columns["Description"]; if (!row.IsNull(dataColumn)) { mappedObject.Description = (string)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Updates a record in the <c>aspnet_Applications</c> table. /// </summary> /// <param name="value">The <see cref="aspnet_ApplicationsRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(aspnet_ApplicationsRow value) { IDbCommand cmd = _db.CreateCommand("dbo._aspnet_Applications_Update", true); AddParameter(cmd, "ApplicationName", value.ApplicationName); AddParameter(cmd, "LoweredApplicationName", value.LoweredApplicationName); AddParameter(cmd, "Description", value.Description); AddParameter(cmd, "ApplicationId", value.ApplicationId); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Adds a new record into the <c>aspnet_Applications</c> table. /// </summary> /// <param name="value">The <see cref="aspnet_ApplicationsRow"/> object to be inserted.</param> public virtual void Insert(aspnet_ApplicationsRow value) { IDbCommand cmd = _db.CreateCommand("dbo._aspnet_Applications_Insert", true); AddParameter(cmd, "ApplicationName", value.ApplicationName); AddParameter(cmd, "LoweredApplicationName", value.LoweredApplicationName); AddParameter(cmd, "ApplicationId", value.ApplicationId); AddParameter(cmd, "Description", value.Description); cmd.ExecuteNonQuery(); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="aspnet_ApplicationsRow"/> objects.</returns> protected virtual aspnet_ApplicationsRow[] MapRecords(IDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int applicationNameColumnIndex = reader.GetOrdinal("ApplicationName"); int loweredApplicationNameColumnIndex = reader.GetOrdinal("LoweredApplicationName"); int applicationIdColumnIndex = reader.GetOrdinal("ApplicationId"); int descriptionColumnIndex = reader.GetOrdinal("Description"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { aspnet_ApplicationsRow record = new aspnet_ApplicationsRow(); recordList.Add(record); record.ApplicationName = Convert.ToString(reader.GetValue(applicationNameColumnIndex)); record.LoweredApplicationName = Convert.ToString(reader.GetValue(loweredApplicationNameColumnIndex)); record.ApplicationId = reader.GetGuid(applicationIdColumnIndex); if (!reader.IsDBNull(descriptionColumnIndex)) { record.Description = Convert.ToString(reader.GetValue(descriptionColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((aspnet_ApplicationsRow[])(recordList.ToArray(typeof(aspnet_ApplicationsRow)))); }
/// <summary> /// Deletes the specified object from the <c>aspnet_Applications</c> table. /// </summary> /// <param name="value">The <see cref="aspnet_ApplicationsRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(aspnet_ApplicationsRow value) { return(DeleteByPrimaryKey(value.ApplicationId)); }