/// <summary> /// Fill method for populating an entire collection of GovernmentReportingCollection /// </summary> public virtual void Fill(GovernmentReportingCollection governmentReportingCollection) { // create the connection to use SqlConnection cnn = new SqlConnection(GovernmentReporting.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectGovernmentReportingCollection"); // Send the collection and data to the object factory CreateObjectsFromData(governmentReportingCollection, 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(GovernmentReporting deleteObject) { // create a new instance of the connection SqlConnection cnn = new SqlConnection(GovernmentReporting.GetConnectionString()); // create local variable array for the sql parameters SqlParameterHash sqlparams = null; try { // discover the parameters sqlparams = SqlHelperParameterCache.GetSpParameterSet(GovernmentReporting.GetConnectionString(), "gsp_DeleteGovernmentReporting"); // 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_DeleteGovernmentReporting", 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 a collection by LOAN_APPLICATION /// </summary> public void FillByLoanApplication(GovernmentReportingCollection governmentReportingCollection, System.Int64 id) { // create the connection to use SqlConnection cnn = new SqlConnection(GovernmentReporting.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(GovernmentReporting.GetConnectionString(), "gsp_SelectGovernmentReportingCollectionByLoanApplication"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@loanApplicationId"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectGovernmentReportingCollectionByLoanApplication", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(governmentReportingCollection, 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(GovernmentReporting governmentreporting, System.Int64 loanApplicationId) { // create the connection to use SqlConnection cnn = new SqlConnection(GovernmentReporting.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(GovernmentReporting.GetConnectionString(), "gsp_SelectGovernmentReporting"); 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_SelectGovernmentReporting", sqlparams); if (datareader.Read()) { governmentreporting.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(GovernmentReporting 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(GovernmentReporting.GetConnectionString()); } try { // discover the parameters if (persistObject.Persisted) { sqlparams = SqlHelperParameterCache.GetSpParameterSet(GovernmentReporting.GetConnectionString(), "gsp_UpdateGovernmentReporting"); } else { sqlparams = SqlHelperParameterCache.GetSpParameterSet(GovernmentReporting.GetConnectionString(), "gsp_CreateGovernmentReporting"); } // Store the parameter for the HMDAPurposeOfLoanType attribute. if (!persistObject.HMDAPurposeOfLoanTypeIsNull) { sqlparams["@hMDAPurposeOfLoanType"].Value = persistObject.HMDAPurposeOfLoanType; } // Store the parameter for the HMDAPreapprovalType attribute. if (!persistObject.HMDAPreapprovalTypeIsNull) { sqlparams["@hMDAPreapprovalType"].Value = persistObject.HMDAPreapprovalType; } // Store the parameter for the HMDA_HOEPALoanStatusIndicator attribute. sqlparams["@hMDA_HOEPALoanStatusIndicator"].Value = persistObject.HMDA_HOEPALoanStatusIndicator; // Store the parameter for the HMDARateSpreadPercent attribute. if (!persistObject.HMDARateSpreadPercentIsNull) { sqlparams["@hMDARateSpreadPercent"].Value = persistObject.HMDARateSpreadPercent; } // 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_CreateGovernmentReporting", sqlparams); } else { SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateGovernmentReporting", 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_CreateGovernmentReporting", sqlparams); } else { SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateGovernmentReporting", sqlparams); } } } catch (SqlException sqlex) { throw sqlex; } }