Beispiel #1
0
        /// <summary>
        /// Adds a new record into the <c>aspnet_UsersInRoles</c> table.
        /// </summary>
        /// <param name="value">The <see cref="aspnet_UsersInRolesRow"/> object to be inserted.</param>
        public virtual void Insert(aspnet_UsersInRolesRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._aspnet_UsersInRoles_Insert", true);

            AddParameter(cmd, "UserId", value.UserId);
            AddParameter(cmd, "RoleId", value.RoleId);
            cmd.ExecuteNonQuery();
        }
Beispiel #2
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="aspnet_UsersInRolesRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="aspnet_UsersInRolesRow"/> object.</returns>
        protected virtual aspnet_UsersInRolesRow MapRow(DataRow row)
        {
            aspnet_UsersInRolesRow mappedObject = new aspnet_UsersInRolesRow();
            DataTable  dataTable = row.Table;
            DataColumn dataColumn;

            // Column "UserId"
            dataColumn = dataTable.Columns["UserId"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.UserId = (System.Guid)row[dataColumn];
            }
            // Column "RoleId"
            dataColumn = dataTable.Columns["RoleId"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.RoleId = (System.Guid)row[dataColumn];
            }
            return(mappedObject);
        }
Beispiel #3
0
        /// <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_UsersInRolesRow"/> objects.</returns>
        protected virtual aspnet_UsersInRolesRow[] 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 userIdColumnIndex = reader.GetOrdinal("UserId");
            int roleIdColumnIndex = reader.GetOrdinal("RoleId");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    aspnet_UsersInRolesRow record = new aspnet_UsersInRolesRow();
                    recordList.Add(record);

                    record.UserId = reader.GetGuid(userIdColumnIndex);
                    record.RoleId = reader.GetGuid(roleIdColumnIndex);

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((aspnet_UsersInRolesRow[])(recordList.ToArray(typeof(aspnet_UsersInRolesRow))));
        }
Beispiel #4
0
 /// <summary>
 /// Deletes the specified object from the <c>aspnet_UsersInRoles</c> table.
 /// </summary>
 /// <param name="value">The <see cref="aspnet_UsersInRolesRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(aspnet_UsersInRolesRow value)
 {
     return(DeleteByPrimaryKey(value.UserId, value.RoleId));
 }