/// <summary>
        /// Returns a <see cref="ApplicationUserList"/> object of the specified criteria.
        /// </summary>
        /// <param name="applicationUserID">No additional detail available.</param>
        /// <returns>A <see cref="ApplicationUserList"/> object of the specified criteria.</returns>
        public static ApplicationUserList GetByApplicationUserID(System.Int32 applicationUserID)
        {
            var criteria = new ApplicationUserCriteria {
                ApplicationUserID = applicationUserID
            };


            return(new ApplicationUserList().DataPortal_Fetch(criteria));
        }
        private ApplicationUserList DataPortal_Fetch(ApplicationUserCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(null);
            }

            //RaiseListChangedEvents = false;

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[spCFM_ApplicationUser_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_LastNameHasValue", criteria.LastNameHasValue);
                    command.Parameters.AddWithValue("@p_EmailAddressHasValue", criteria.EmailAddressHasValue);
                    command.Parameters.AddWithValue("@p_MobilePhoneHasValue", criteria.MobilePhoneHasValue);
                    command.Parameters.AddWithValue("@p_WorkPhoneHasValue", criteria.WorkPhoneHasValue);
                    command.Parameters.AddWithValue("@p_EmployeeNumberHasValue", criteria.EmployeeNumberHasValue);
                    command.Parameters.AddWithValue("@p_PasswordResetTokenHasValue", criteria.PasswordResetTokenHasValue);
                    command.Parameters.AddWithValue("@p_PasswordResetTokenExpiryHasValue", criteria.PasswordResetTokenExpiryHasValue);
                    command.Parameters.AddWithValue("@p_ApplicationRoleIDHasValue", criteria.ApplicationRoleIDHasValue);
                    command.Parameters.AddWithValue("@p_LastLoggedOnHasValue", criteria.LastLoggedOnHasValue);
                    command.Parameters.AddWithValue("@p_StatementDeliveryOptionIDHasValue", criteria.StatementDeliveryOptionIDHasValue);
                    command.Parameters.AddWithValue("@p_PhysicalAddressIDHasValue", criteria.PhysicalAddressIDHasValue);
                    command.Parameters.AddWithValue("@p_PostalAddressIDHasValue", criteria.PostalAddressIDHasValue);
                    command.Parameters.AddWithValue("@p_LastActiveCheckSentOnHasValue", criteria.LastActiveCheckSentOnHasValue);
                    command.Parameters.AddWithValue("@p_CreatedByHasValue", criteria.CreatedByHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue);
                    command.Parameters.AddWithValue("@p_LastPasswordChangedOnHasValue", criteria.LastPasswordChangedOnHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            var rowParser = reader.GetRowParser <CFMData.ApplicationUser>();
                            do
                            {
                                this.Add(CFMData.ApplicationUser.GetApplicationUser(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
        /// <summary>
        /// Returns a <see cref="ApplicationUserList"/> object of the specified criteria.
        /// </summary>
        /// <param name="postalAddressID">No additional detail available.</param>
        /// <returns>A <see cref="ApplicationUserList"/> object of the specified criteria.</returns>
        public static ApplicationUserList GetByPostalAddressID(System.Int32?postalAddressID)
        {
            var criteria = new ApplicationUserCriteria {
            };

            if (postalAddressID.HasValue)
            {
                criteria.PostalAddressID = postalAddressID.Value;
            }

            return(new ApplicationUserList().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="ApplicationUserList"/> object of the specified criteria.
        /// </summary>
        /// <param name="statementDeliveryOptionID">No additional detail available.</param>
        /// <returns>A <see cref="ApplicationUserList"/> object of the specified criteria.</returns>
        public static ApplicationUserList GetByStatementDeliveryOptionID(System.Int32?statementDeliveryOptionID)
        {
            var criteria = new ApplicationUserCriteria {
            };

            if (statementDeliveryOptionID.HasValue)
            {
                criteria.StatementDeliveryOptionID = statementDeliveryOptionID.Value;
            }

            return(new ApplicationUserList().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="ApplicationUserList"/> object of the specified criteria.
        /// </summary>
        /// <param name="updatedBy">No additional detail available.</param>
        /// <returns>A <see cref="ApplicationUserList"/> object of the specified criteria.</returns>
        public static ApplicationUserList GetByUpdatedBy(System.Int32?updatedBy)
        {
            var criteria = new ApplicationUserCriteria {
            };

            if (updatedBy.HasValue)
            {
                criteria.UpdatedBy = updatedBy.Value;
            }

            return(new ApplicationUserList().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="ApplicationUserList"/> object of the specified criteria.
        /// </summary>
        /// <param name="applicationRoleID">No additional detail available.</param>
        /// <returns>A <see cref="ApplicationUserList"/> object of the specified criteria.</returns>
        public static ApplicationUserList GetByApplicationRoleID(System.Int32?applicationRoleID)
        {
            var criteria = new ApplicationUserCriteria {
            };

            if (applicationRoleID.HasValue)
            {
                criteria.ApplicationRoleID = applicationRoleID.Value;
            }

            return(new ApplicationUserList().DataPortal_Fetch(criteria));
        }
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="ApplicationUser"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="ApplicationUserCriteria"/> object containing the criteria of the object to fetch.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object fetching should proceed.</param>
 partial void OnFetching(ApplicationUserCriteria criteria, ref bool cancel);
        public static ApplicationUserList GetByCriteria(ApplicationUserCriteria criteria)
        {
            return(new ApplicationUserList().DataPortal_Fetch(criteria));
//            return DataPortal.Fetch<ApplicationUserList>(criteria);
        }