/// <summary>
        /// Persists the object.
        /// </summary>
        public virtual void Persist(LoanFeatures persistObject, SqlTransaction sqlTrans)
        {
            // create local variable array for the sql parameters
            SqlParameterHash sqlparams = null;
            // Create a local variable for the connection
            SqlConnection cnn = null;

            // Use the parameter overload or create a new instance
            if (sqlTrans == null)
                cnn = new SqlConnection(LoanFeatures.GetConnectionString());

            try
            {
                // discover the parameters
                if (persistObject.Persisted)
                    sqlparams =  SqlHelperParameterCache.GetSpParameterSet(LoanFeatures.GetConnectionString(), "gsp_UpdateLoanFeatures");
                else
                    sqlparams =  SqlHelperParameterCache.GetSpParameterSet(LoanFeatures.GetConnectionString(), "gsp_CreateLoanFeatures");

                // Store the parameter for the AssumabilityIndicator attribute.
                sqlparams["@assumabilityIndicator"].Value = persistObject.AssumabilityIndicator;
                // Store the parameter for the BalloonIndicator attribute.
                sqlparams["@balloonIndicator"].Value = persistObject.BalloonIndicator;
                // Store the parameter for the BalloonLoanMaturityTermMonths attribute.
                if (!persistObject.BalloonLoanMaturityTermMonthsIsNull)
                    sqlparams["@balloonLoanMaturityTermMonths"].Value = persistObject.BalloonLoanMaturityTermMonths;
                // Store the parameter for the BuydownTemporarySubsidyIndicator attribute.
                sqlparams["@buydownTemporarySubsidyIndicator"].Value = persistObject.BuydownTemporarySubsidyIndicator;
                // Store the parameter for the CounselingConfirmationIndicator attribute.
                sqlparams["@counselingConfirmationIndicator"].Value = persistObject.CounselingConfirmationIndicator;
                // Store the parameter for the EscrowWaiverIndicator attribute.
                sqlparams["@escrowWaiverIndicator"].Value = persistObject.EscrowWaiverIndicator;
                // Store the parameter for the FREOfferingIdentifier attribute.
                if (!persistObject.FREOfferingIdentifierIsNull)
                    sqlparams["@fREOfferingIdentifier"].Value = persistObject.FREOfferingIdentifier;
                // Store the parameter for the FNMProductPlanIdentifier attribute.
                if (!persistObject.FNMProductPlanIdentifierIsNull)
                    sqlparams["@fNMProductPlanIdentifier"].Value = persistObject.FNMProductPlanIdentifier;
                // Store the parameter for the FNMProductPlanIndentifier attribute.
                if (!persistObject.FNMProductPlanIndentifierIsNull)
                    sqlparams["@fNMProductPlanIndentifier"].Value = persistObject.FNMProductPlanIndentifier;
                // Store the parameter for the HELOCMaximumBalanceAmount attribute.
                if (!persistObject.HELOCMaximumBalanceAmountIsNull)
                    sqlparams["@hELOCMaximumBalanceAmount"].Value = persistObject.HELOCMaximumBalanceAmount;
                // Store the parameter for the HELOCInitialAdvanceAmount attribute.
                if (!persistObject.HELOCInitialAdvanceAmountIsNull)
                    sqlparams["@hELOCInitialAdvanceAmount"].Value = persistObject.HELOCInitialAdvanceAmount;
                // Store the parameter for the InterestOnlyTerm attribute.
                if (!persistObject.InterestOnlyTermIsNull)
                    sqlparams["@interestOnlyTerm"].Value = persistObject.InterestOnlyTerm;
                // Store the parameter for the LenderSelfInsuredIndicator attribute.
                sqlparams["@lenderSelfInsuredIndicator"].Value = persistObject.LenderSelfInsuredIndicator;
                // Store the parameter for the LoanScheduledClosingDate attribute.
                if (!persistObject.LoanScheduledClosingDateIsNull)
                    sqlparams["@loanScheduledClosingDate"].Value = persistObject.LoanScheduledClosingDate;
                // Store the parameter for the MICoveragePercent attribute.
                if (!persistObject.MICoveragePercentIsNull)
                    sqlparams["@mICoveragePercent"].Value = persistObject.MICoveragePercent;
                // Store the parameter for the NegativeAmortizationLimitPercent attribute.
                if (!persistObject.NegativeAmortizationLimitPercentIsNull)
                    sqlparams["@negativeAmortizationLimitPercent"].Value = persistObject.NegativeAmortizationLimitPercent;
                // Store the parameter for the PrepaymentPenaltyIndicator attribute.
                sqlparams["@prepaymentPenaltyIndicator"].Value = persistObject.PrepaymentPenaltyIndicator;
                // Store the parameter for the PrepaymentPenaltyTermMonths attribute.
                if (!persistObject.PrepaymentPenaltyTermMonthsIsNull)
                    sqlparams["@prepaymentPenaltyTermMonths"].Value = persistObject.PrepaymentPenaltyTermMonths;
                // Store the parameter for the PrepaymentRestrictionIndicator attribute.
                sqlparams["@prepaymentRestrictionIndicator"].Value = persistObject.PrepaymentRestrictionIndicator;
                // Store the parameter for the ProductDescription attribute.
                if (!persistObject.ProductDescriptionIsNull)
                    sqlparams["@productDescription"].Value = persistObject.ProductDescription;
                // Store the parameter for the ProductName attribute.
                if (!persistObject.ProductNameIsNull)
                    sqlparams["@productName"].Value = persistObject.ProductName;
                // Store the parameter for the ScheduledFirstPaymentDate attribute.
                if (!persistObject.ScheduledFirstPaymentDateIsNull)
                    sqlparams["@scheduledFirstPaymentDate"].Value = persistObject.ScheduledFirstPaymentDate;
                // Store the parameter for the NameDocumentsDrawnInType attribute.
                if (!persistObject.NameDocumentsDrawnInTypeIsNull)
                    sqlparams["@nameDocumentsDrawnInType"].Value = persistObject.NameDocumentsDrawnInType;
                // Store the parameter for the GSEProjectClassificationType attribute.
                if (!persistObject.GSEProjectClassificationTypeIsNull)
                    sqlparams["@gSEProjectClassificationType"].Value = persistObject.GSEProjectClassificationType;
                // Store the parameter for the GSEPropertyType attribute.
                if (!persistObject.GSEPropertyTypeIsNull)
                    sqlparams["@gSEPropertyType"].Value = persistObject.GSEPropertyType;
                // Store the parameter for the LienPriorityType attribute.
                if (!persistObject.LienPriorityTypeIsNull)
                    sqlparams["@lienPriorityType"].Value = persistObject.LienPriorityType;
                // Store the parameter for the LoanDocumentationType attribute.
                if (!persistObject.LoanDocumentationTypeIsNull)
                    sqlparams["@loanDocumentationType"].Value = persistObject.LoanDocumentationType;
                // Store the parameter for the LoanRepaymentType attribute.
                if (!persistObject.LoanRepaymentTypeIsNull)
                    sqlparams["@loanRepaymentType"].Value = persistObject.LoanRepaymentType;
                // Store the parameter for the MICertificationStatusType attribute.
                if (!persistObject.MICertificationStatusTypeIsNull)
                    sqlparams["@mICertificationStatusType"].Value = persistObject.MICertificationStatusType;
                // Store the parameter for the MICompanyNameType attribute.
                if (!persistObject.MICompanyNameTypeIsNull)
                    sqlparams["@mICompanyNameType"].Value = persistObject.MICompanyNameType;
                // Store the parameter for the PaymentFrequencyType attribute.
                if (!persistObject.PaymentFrequencyTypeIsNull)
                    sqlparams["@paymentFrequencyType"].Value = persistObject.PaymentFrequencyType;
                // Store the parameter for the FullPrepaymentPenaltyOptionType attribute.
                if (!persistObject.FullPrepaymentPenaltyOptionTypeIsNull)
                    sqlparams["@fullPrepaymentPenaltyOptionType"].Value = persistObject.FullPrepaymentPenaltyOptionType;
                // Store the parameter for the LoanClosingStatusType attribute.
                if (!persistObject.LoanClosingStatusTypeIsNull)
                    sqlparams["@loanClosingStatusType"].Value = persistObject.LoanClosingStatusType;
                // Store the parameter for the ServicingTransferStatusType attribute.
                if (!persistObject.ServicingTransferStatusTypeIsNull)
                    sqlparams["@servicingTransferStatusType"].Value = persistObject.ServicingTransferStatusType;
                // Store the parameter for the LoanApplicationId attribute.
                sqlparams["@loanApplicationId"].Value = persistObject.LoanApplicationId;
                if (!persistObject.Persisted)
                {
                    // store the create only (historical fixed) values
                }
                else
                {
                    // store the update only (historical changeable) values
                }

                if (sqlTrans == null)
                {
                    // Process using the isolated connection
                    using (cnn)
                    {
                        // open the connection
                        cnn.Open();

                        if (!persistObject.Persisted)
                        {
                            SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_CreateLoanFeatures", sqlparams);
                        }
                        else
                        {
                            SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateLoanFeatures", sqlparams);
                        }

                        // close the connection after usage
                        cnn.Close();
                    }

                    // nullify the connection var
                    cnn = null;
                }
                else
                {
                    // Process using the shared transaction
                    if (!persistObject.Persisted)
                    {
                        SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_CreateLoanFeatures", sqlparams);
                    }
                    else
                    {
                        SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateLoanFeatures", sqlparams);
                    }
                }
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
        /// <summary>
        /// Fills a single instance with data based on its primary key values.
        /// </summary>
        public virtual void Fill(LoanFeatures loanfeatures, System.Int64 loanApplicationId)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(LoanFeatures.GetConnectionString());
            try
            {
                // discover the sql parameters
                SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(LoanFeatures.GetConnectionString(), "gsp_SelectLoanFeatures");

                using (cnn)
                {
                    // open the connection
                    cnn.Open();

                    // set the parameters
                    sqlparams["@loanApplicationId"].Value = loanApplicationId;

                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectLoanFeatures", sqlparams);

                    if (datareader.Read())
                        loanfeatures.SetMembers(ref datareader);

                    cnn.Close(); // close the connection
                }

                // nullify the connection var
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
 /// <summary>
 /// Persists the object.
 /// </summary>
 public virtual void Persist(LoanFeatures persistObject)
 {
     // Make a call to the overloaded method with a null transaction
     Persist(persistObject, null);
 }
        /// <summary>
        /// Deletes the object.
        /// </summary>
        public virtual void Delete(LoanFeatures deleteObject)
        {
            // create a new instance of the connection
            SqlConnection cnn = new SqlConnection(LoanFeatures.GetConnectionString());
            // create local variable array for the sql parameters
            SqlParameterHash sqlparams = null;

            try
            {
                // discover the parameters
                sqlparams =  SqlHelperParameterCache.GetSpParameterSet(LoanFeatures.GetConnectionString(), "gsp_DeleteLoanFeatures");

                // Store the parameter for the LoanApplicationId attribute.
                sqlparams["@loanApplicationId"].Value = deleteObject.LoanApplicationId;

                using (cnn)
                {
                    // open the connection
                    cnn.Open();

                    // Execute the stored proc to perform the delete on the instance.
                    SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_DeleteLoanFeatures", sqlparams);

                    // close the connection after usage
                    cnn.Close();
                }

                // nullify the connection var
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }

            // nullify the reference
            deleteObject = null;
        }