/// <summary> /// Fills a single instance with data based on its primary key values. /// </summary> public virtual void Fill(MortgageTerms mortgageterms, System.Int64 loanApplicationId) { // create the connection to use SqlConnection cnn = new SqlConnection(MortgageTerms.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(MortgageTerms.GetConnectionString(), "gsp_SelectMortgageTerms"); 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_SelectMortgageTerms", sqlparams); if (datareader.Read()) mortgageterms.SetMembers(ref datareader); cnn.Close(); // close the connection } // nullify the connection var cnn = null; } catch (SqlException sqlex) { throw sqlex; } }