/// <summary> /// Fill method for populating an entire collection of TransactionDetails /// </summary> public virtual void Fill(TransactionDetails transactionDetails) { // create the connection to use SqlConnection cnn = new SqlConnection(TransactionDetail.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectTransactionDetails"); // Send the collection and data to the object factory CreateObjectsFromData(transactionDetails, 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(TransactionDetail deleteObject) { // create a new instance of the connection SqlConnection cnn = new SqlConnection(TransactionDetail.GetConnectionString()); // create local variable array for the sql parameters SqlParameterHash sqlparams = null; try { // discover the parameters sqlparams = SqlHelperParameterCache.GetSpParameterSet(TransactionDetail.GetConnectionString(), "gsp_DeleteTransactionDetail"); // 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_DeleteTransactionDetail", 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(TransactionDetails transactionDetails, System.Int64 id) { // create the connection to use SqlConnection cnn = new SqlConnection(TransactionDetail.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(TransactionDetail.GetConnectionString(), "gsp_SelectTransactionDetailsByLoanApplication"); 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_SelectTransactionDetailsByLoanApplication", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(transactionDetails, 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(TransactionDetail transactiondetail, System.Int64 loanApplicationId) { // create the connection to use SqlConnection cnn = new SqlConnection(TransactionDetail.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(TransactionDetail.GetConnectionString(), "gsp_SelectTransactionDetail"); 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_SelectTransactionDetail", sqlparams); if (datareader.Read()) { transactiondetail.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(TransactionDetail 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(TransactionDetail.GetConnectionString()); } try { // discover the parameters if (persistObject.Persisted) { sqlparams = SqlHelperParameterCache.GetSpParameterSet(TransactionDetail.GetConnectionString(), "gsp_UpdateTransactionDetail"); } else { sqlparams = SqlHelperParameterCache.GetSpParameterSet(TransactionDetail.GetConnectionString(), "gsp_CreateTransactionDetail"); } // Store the parameter for the AlterationsImprovementsAndRepairsAmount attribute. if (!persistObject.AlterationsImprovementsAndRepairsAmountIsNull) { sqlparams["@alterationsImprovementsAndRepairsAmount"].Value = persistObject.AlterationsImprovementsAndRepairsAmount; } // Store the parameter for the BorrowerPaidDiscountPointsTotalAmount attribute. if (!persistObject.BorrowerPaidDiscountPointsTotalAmountIsNull) { sqlparams["@borrowerPaidDiscountPointsTotalAmount"].Value = persistObject.BorrowerPaidDiscountPointsTotalAmount; } // Store the parameter for the EstimatedClosingCostsAmount attribute. if (!persistObject.EstimatedClosingCostsAmountIsNull) { sqlparams["@estimatedClosingCostsAmount"].Value = persistObject.EstimatedClosingCostsAmount; } // Store the parameter for the MIAndFundingFeeFinancedAmount attribute. if (!persistObject.MIAndFundingFeeFinancedAmountIsNull) { sqlparams["@mIAndFundingFeeFinancedAmount"].Value = persistObject.MIAndFundingFeeFinancedAmount; } // Store the parameter for the MIAndFundingFeeTotalAmount attribute. if (!persistObject.MIAndFundingFeeTotalAmountIsNull) { sqlparams["@mIAndFundingFeeTotalAmount"].Value = persistObject.MIAndFundingFeeTotalAmount; } // Store the parameter for the PrepaidItemsEstimatedAmount attribute. if (!persistObject.PrepaidItemsEstimatedAmountIsNull) { sqlparams["@prepaidItemsEstimatedAmount"].Value = persistObject.PrepaidItemsEstimatedAmount; } // Store the parameter for the PurchasePriceAmount attribute. if (!persistObject.PurchasePriceAmountIsNull) { sqlparams["@purchasePriceAmount"].Value = persistObject.PurchasePriceAmount; } // Store the parameter for the RefinanceIncludingDebtsToBePaidOffAmount attribute. if (!persistObject.RefinanceIncludingDebtsToBePaidOffAmountIsNull) { sqlparams["@refinanceIncludingDebtsToBePaidOffAmount"].Value = persistObject.RefinanceIncludingDebtsToBePaidOffAmount; } // Store the parameter for the SalesConcessionAmount attribute. if (!persistObject.SalesConcessionAmountIsNull) { sqlparams["@salesConcessionAmount"].Value = persistObject.SalesConcessionAmount; } // Store the parameter for the SellerPaidClosingCostsAmount attribute. if (!persistObject.SellerPaidClosingCostsAmountIsNull) { sqlparams["@sellerPaidClosingCostsAmount"].Value = persistObject.SellerPaidClosingCostsAmount; } // Store the parameter for the SubordinateLienAmount attribute. if (!persistObject.SubordinateLienAmountIsNull) { sqlparams["@subordinateLienAmount"].Value = persistObject.SubordinateLienAmount; } // Store the parameter for the SubordinateLienHELOCAmount attribute. if (!persistObject.SubordinateLienHELOCAmountIsNull) { sqlparams["@subordinateLienHELOCAmount"].Value = persistObject.SubordinateLienHELOCAmount; } // Store the parameter for the FREReserveAmount attribute. if (!persistObject.FREReserveAmountIsNull) { sqlparams["@fREReserveAmount"].Value = persistObject.FREReserveAmount; } // Store the parameter for the FREReservesAmount attribute. if (!persistObject.FREReservesAmountIsNull) { sqlparams["@fREReservesAmount"].Value = persistObject.FREReservesAmount; } // 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_CreateTransactionDetail", sqlparams); } else { SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateTransactionDetail", 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_CreateTransactionDetail", sqlparams); } else { SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateTransactionDetail", sqlparams); } } } catch (SqlException sqlex) { throw sqlex; } }