示例#1
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_UsersRow"/> objects.</returns>
        protected virtual aspnet_UsersRow[] 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 applicationIdColumnIndex    = reader.GetOrdinal("ApplicationId");
            int userIdColumnIndex           = reader.GetOrdinal("UserId");
            int userNameColumnIndex         = reader.GetOrdinal("UserName");
            int loweredUserNameColumnIndex  = reader.GetOrdinal("LoweredUserName");
            int mobileAliasColumnIndex      = reader.GetOrdinal("MobileAlias");
            int isAnonymousColumnIndex      = reader.GetOrdinal("IsAnonymous");
            int lastActivityDateColumnIndex = reader.GetOrdinal("LastActivityDate");

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

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

                    record.ApplicationId   = reader.GetGuid(applicationIdColumnIndex);
                    record.UserId          = reader.GetGuid(userIdColumnIndex);
                    record.UserName        = Convert.ToString(reader.GetValue(userNameColumnIndex));
                    record.LoweredUserName = Convert.ToString(reader.GetValue(loweredUserNameColumnIndex));
                    if (!reader.IsDBNull(mobileAliasColumnIndex))
                    {
                        record.MobileAlias = Convert.ToString(reader.GetValue(mobileAliasColumnIndex));
                    }
                    record.IsAnonymous      = Convert.ToBoolean(reader.GetValue(isAnonymousColumnIndex));
                    record.LastActivityDate = Convert.ToDateTime(reader.GetValue(lastActivityDateColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((aspnet_UsersRow[])(recordList.ToArray(typeof(aspnet_UsersRow))));
        }
示例#2
0
        /// <summary>
        /// Updates a record in the <c>aspnet_Users</c> table.
        /// </summary>
        /// <param name="value">The <see cref="aspnet_UsersRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(aspnet_UsersRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._aspnet_Users_Update", true);

            AddParameter(cmd, "ApplicationId", value.ApplicationId);
            AddParameter(cmd, "UserName", value.UserName);
            AddParameter(cmd, "LoweredUserName", value.LoweredUserName);
            AddParameter(cmd, "MobileAlias", value.MobileAlias);
            AddParameter(cmd, "IsAnonymous", value.IsAnonymous);
            AddParameter(cmd, "LastActivityDate", value.LastActivityDate);
            AddParameter(cmd, "UserId", value.UserId);
            return(0 != cmd.ExecuteNonQuery());
        }
示例#3
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="aspnet_UsersRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="aspnet_UsersRow"/> object.</returns>
        protected virtual aspnet_UsersRow MapRow(DataRow row)
        {
            aspnet_UsersRow mappedObject = new aspnet_UsersRow();
            DataTable       dataTable    = row.Table;
            DataColumn      dataColumn;

            // Column "ApplicationId"
            dataColumn = dataTable.Columns["ApplicationId"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.ApplicationId = (System.Guid)row[dataColumn];
            }
            // Column "UserId"
            dataColumn = dataTable.Columns["UserId"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.UserId = (System.Guid)row[dataColumn];
            }
            // Column "UserName"
            dataColumn = dataTable.Columns["UserName"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.UserName = (string)row[dataColumn];
            }
            // Column "LoweredUserName"
            dataColumn = dataTable.Columns["LoweredUserName"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.LoweredUserName = (string)row[dataColumn];
            }
            // Column "MobileAlias"
            dataColumn = dataTable.Columns["MobileAlias"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.MobileAlias = (string)row[dataColumn];
            }
            // Column "IsAnonymous"
            dataColumn = dataTable.Columns["IsAnonymous"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.IsAnonymous = (bool)row[dataColumn];
            }
            // Column "LastActivityDate"
            dataColumn = dataTable.Columns["LastActivityDate"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.LastActivityDate = (System.DateTime)row[dataColumn];
            }
            return(mappedObject);
        }
示例#4
0
 /// <summary>
 /// Deletes the specified object from the <c>aspnet_Users</c> table.
 /// </summary>
 /// <param name="value">The <see cref="aspnet_UsersRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(aspnet_UsersRow value)
 {
     return(DeleteByPrimaryKey(value.UserId));
 }