/// <summary> /// Fill method for populating an entire collection of Borrowers /// </summary> public virtual void Fill(Borrowers borrowers) { // create the connection to use SqlConnection cnn = new SqlConnection(Borrower.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectBorrowers"); // Send the collection and data to the object factory CreateObjectsFromData(borrowers, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// Deletes the object. /// </summary> public virtual void Delete(Borrower deleteObject) { // create a new instance of the connection SqlConnection cnn = new SqlConnection(Borrower.GetConnectionString()); // create local variable array for the sql parameters SqlParameterHash sqlparams = null; try { // discover the parameters sqlparams = SqlHelperParameterCache.GetSpParameterSet(Borrower.GetConnectionString(), "gsp_DeleteBorrower"); // Store the parameter for the Id attribute. sqlparams["@id"].Value = deleteObject.Id; using (cnn) { // open the connection cnn.Open(); // Execute the stored proc to perform the delete on the instance. SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_DeleteBorrower", sqlparams); // close the connection after usage cnn.Close(); } // nullify the connection var cnn = null; } catch (SqlException sqlex) { throw sqlex; } // nullify the reference deleteObject = null; }
/// <summary> /// Fill method for populating an entire collection of Borrowers using the selection service GetBySSN /// </summary> public virtual void GetBySSN(Borrowers borrowers, System.String sSN) { // create the connection to use SqlConnection cnn = new SqlConnection(Borrower.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Borrower.GetConnectionString(), "gsp_BorrowersGetBySSN"); using (cnn) { // open the connection cnn.Open(); // Start setting the requirement SP parameters sqlparams["@sSN"].Value = sSN; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_BorrowersGetBySSN", sqlparams); // Send the collection and data to the object factory CreateObjectsFromData(borrowers, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// Fill method for populating a collection by PrintPositionType /// </summary> public void FillByPrintPositionType(Borrowers borrowers, System.Int16 id) { // create the connection to use SqlConnection cnn = new SqlConnection(Borrower.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Borrower.GetConnectionString(), "gsp_SelectBorrowersByPrintPositionType"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@printPositionType"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectBorrowersByPrintPositionType", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(borrowers, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// Fills a single instance with data based on its primary key values. /// </summary> public virtual void Fill(Borrower borrower, System.Int64 id) { // create the connection to use SqlConnection cnn = new SqlConnection(Borrower.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Borrower.GetConnectionString(), "gsp_SelectBorrower"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@id"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectBorrower", sqlparams); if (datareader.Read()) { borrower.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(Borrower 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(Borrower.GetConnectionString()); } try { // discover the parameters if (persistObject.Persisted) { sqlparams = SqlHelperParameterCache.GetSpParameterSet(Borrower.GetConnectionString(), "gsp_UpdateBorrower"); } else { sqlparams = SqlHelperParameterCache.GetSpParameterSet(Borrower.GetConnectionString(), "gsp_CreateBorrower"); } // Store the parameter for the JointAssetBorrowerID attribute. if (!persistObject.JointAssetBorrowerIDIsNull) { sqlparams["@jointAssetBorrowerID"].Value = persistObject.JointAssetBorrowerID; } // Store the parameter for the LoanApplicationId attribute. if (!persistObject.LoanApplicationIdIsNull) { sqlparams["@loanApplicationId"].Value = persistObject.LoanApplicationId; } // Store the parameter for the FirstName attribute. if (!persistObject.FirstNameIsNull) { sqlparams["@firstName"].Value = persistObject.FirstName; } // Store the parameter for the MiddleName attribute. if (!persistObject.MiddleNameIsNull) { sqlparams["@middleName"].Value = persistObject.MiddleName; } // Store the parameter for the LastName attribute. if (!persistObject.LastNameIsNull) { sqlparams["@lastName"].Value = persistObject.LastName; } // Store the parameter for the NameSuffix attribute. if (!persistObject.NameSuffixIsNull) { sqlparams["@nameSuffix"].Value = persistObject.NameSuffix; } // Store the parameter for the AgeAtApplicationYears attribute. if (!persistObject.AgeAtApplicationYearsIsNull) { sqlparams["@ageAtApplicationYears"].Value = persistObject.AgeAtApplicationYears; } // Store the parameter for the BirthDate attribute. if (!persistObject.BirthDateIsNull) { sqlparams["@birthDate"].Value = persistObject.BirthDate; } // Store the parameter for the ApplicationSignedDate attribute. if (!persistObject.ApplicationSignedDateIsNull) { sqlparams["@applicationSignedDate"].Value = persistObject.ApplicationSignedDate; } // Store the parameter for the HomeTelephoneNumber attribute. if (!persistObject.HomeTelephoneNumberIsNull) { sqlparams["@homeTelephoneNumber"].Value = persistObject.HomeTelephoneNumber; } // Store the parameter for the SSN attribute. if (!persistObject.SSNIsNull) { sqlparams["@sSN"].Value = persistObject.SSN; } // Store the parameter for the DependentCount attribute. if (!persistObject.DependentCountIsNull) { sqlparams["@dependentCount"].Value = persistObject.DependentCount; } // Store the parameter for the SchoolingYears attribute. if (!persistObject.SchoolingYearsIsNull) { sqlparams["@schoolingYears"].Value = persistObject.SchoolingYears; } // Store the parameter for the CreditReportIdentifier attribute. if (!persistObject.CreditReportIdentifierIsNull) { sqlparams["@creditReportIdentifier"].Value = persistObject.CreditReportIdentifier; } // Store the parameter for the MaritalStatusType attribute. if (!persistObject.MaritalStatusTypeIsNull) { sqlparams["@maritalStatusType"].Value = persistObject.MaritalStatusType; } // Store the parameter for the PrintPositionType attribute. if (!persistObject.PrintPositionTypeIsNull) { sqlparams["@printPositionType"].Value = persistObject.PrintPositionType; } // Store the parameter for the JointAssetLiabilityReportingType attribute. if (!persistObject.JointAssetLiabilityReportingTypeIsNull) { sqlparams["@jointAssetLiabilityReportingType"].Value = persistObject.JointAssetLiabilityReportingType; } // Store the parameter for the Id attribute. if (!persistObject.Persisted) { // store the create only (historical fixed) values } else { // store the update only (historical changeable) values // Store the parameter for the Id attribute. sqlparams["@id"].Value = persistObject.Id; } if (sqlTrans == null) { // Process using the isolated connection using (cnn) { // open the connection cnn.Open(); if (!persistObject.Persisted) { persistObject._id = Convert.ToInt64(SqlHelper.ExecuteScalar(cnn, CommandType.StoredProcedure, "gsp_CreateBorrower", sqlparams)); } else { SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateBorrower", sqlparams); } // close the connection after usage cnn.Close(); } // nullify the connection var cnn = null; } else { // Process using the shared transaction if (!persistObject.Persisted) { persistObject._id = Convert.ToInt64(SqlHelper.ExecuteScalar(sqlTrans, CommandType.StoredProcedure, "gsp_CreateBorrower", sqlparams)); } else { SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateBorrower", sqlparams); } } } catch (SqlException sqlex) { throw sqlex; } }