/// <summary> /// Fill method for populating an entire collection of Declarations /// </summary> public virtual void Fill(Declarations declarations) { // create the connection to use SqlConnection cnn = new SqlConnection(Declaration.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDeclarations"); // Send the collection and data to the object factory CreateObjectsFromData(declarations, 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(Declaration deleteObject) { // create a new instance of the connection SqlConnection cnn = new SqlConnection(Declaration.GetConnectionString()); // create local variable array for the sql parameters SqlParameterHash sqlparams = null; try { // discover the parameters sqlparams = SqlHelperParameterCache.GetSpParameterSet(Declaration.GetConnectionString(), "gsp_DeleteDeclaration"); // Store the parameter for the BorrowerId attribute. sqlparams["@borrowerId"].Value = deleteObject.BorrowerId; using (cnn) { // open the connection cnn.Open(); // Execute the stored proc to perform the delete on the instance. SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_DeleteDeclaration", 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 PriorPropertyTitleType /// </summary> public void FillByPriorPropertyTitleType(Declarations declarations, System.Int16 id) { // create the connection to use SqlConnection cnn = new SqlConnection(Declaration.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Declaration.GetConnectionString(), "gsp_SelectDeclarationsByPriorPropertyTitleType"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@priorPropertyTitleType"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDeclarationsByPriorPropertyTitleType", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(declarations, 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(Declaration declaration, System.Int64 borrowerId) { // create the connection to use SqlConnection cnn = new SqlConnection(Declaration.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Declaration.GetConnectionString(), "gsp_SelectDeclaration"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@borrowerId"].Value = borrowerId; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDeclaration", sqlparams); if (datareader.Read()) { declaration.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(Declaration 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(Declaration.GetConnectionString()); } try { // discover the parameters if (persistObject.Persisted) { sqlparams = SqlHelperParameterCache.GetSpParameterSet(Declaration.GetConnectionString(), "gsp_UpdateDeclaration"); } else { sqlparams = SqlHelperParameterCache.GetSpParameterSet(Declaration.GetConnectionString(), "gsp_CreateDeclaration"); } // Store the parameter for the AlimonyChildSupportObligationIndicator attribute. sqlparams["@alimonyChildSupportObligationIndicator"].Value = persistObject.AlimonyChildSupportObligationIndicator; // Store the parameter for the BankruptcyIndicator attribute. sqlparams["@bankruptcyIndicator"].Value = persistObject.BankruptcyIndicator; // Store the parameter for the BorrowedDownPaymentIndicator attribute. sqlparams["@borrowedDownPaymentIndicator"].Value = persistObject.BorrowedDownPaymentIndicator; // Store the parameter for the CoMakerEndorserOfNoteIndicator attribute. sqlparams["@coMakerEndorserOfNoteIndicator"].Value = persistObject.CoMakerEndorserOfNoteIndicator; // Store the parameter for the HomeownerPastThreeYearsType attribute. if (!persistObject.HomeownerPastThreeYearsTypeIsNull) { sqlparams["@homeownerPastThreeYearsType"].Value = persistObject.HomeownerPastThreeYearsType; } // Store the parameter for the IntentToOccupyType attribute. if (!persistObject.IntentToOccupyTypeIsNull) { sqlparams["@intentToOccupyType"].Value = persistObject.IntentToOccupyType; } // Store the parameter for the LoanForeclosureOrJudgementIndicator attribute. sqlparams["@loanForeclosureOrJudgementIndicator"].Value = persistObject.LoanForeclosureOrJudgementIndicator; // Store the parameter for the OutstandingJudgementsIndicator attribute. sqlparams["@outstandingJudgementsIndicator"].Value = persistObject.OutstandingJudgementsIndicator; // Store the parameter for the PartyToLawsuitIndicator attribute. sqlparams["@partyToLawsuitIndicator"].Value = persistObject.PartyToLawsuitIndicator; // Store the parameter for the PresentlyDelinquentIndicator attribute. sqlparams["@presentlyDelinquentIndicator"].Value = persistObject.PresentlyDelinquentIndicator; // Store the parameter for the PropertyForeclosedPastSevenYearsIndicator attribute. sqlparams["@propertyForeclosedPastSevenYearsIndicator"].Value = persistObject.PropertyForeclosedPastSevenYearsIndicator; // Store the parameter for the CitizenshipResidencyType attribute. if (!persistObject.CitizenshipResidencyTypeIsNull) { sqlparams["@citizenshipResidencyType"].Value = persistObject.CitizenshipResidencyType; } // Store the parameter for the PriorPropertyTitleType attribute. if (!persistObject.PriorPropertyTitleTypeIsNull) { sqlparams["@priorPropertyTitleType"].Value = persistObject.PriorPropertyTitleType; } // Store the parameter for the PriorPropertyUsageType attribute. if (!persistObject.PriorPropertyUsageTypeIsNull) { sqlparams["@priorPropertyUsageType"].Value = persistObject.PriorPropertyUsageType; } // Store the parameter for the BorrowerId attribute. sqlparams["@borrowerId"].Value = persistObject.BorrowerId; 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_CreateDeclaration", sqlparams); } else { SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateDeclaration", 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_CreateDeclaration", sqlparams); } else { SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateDeclaration", sqlparams); } } } catch (SqlException sqlex) { throw sqlex; } }