/// <summary> /// Fill method for populating a collection by FNMCreditReportScoreType /// </summary> public void FillByFNMCreditReportScoreType(FHAVABorrowers fHAVABorrowers, System.Int16 id) { // create the connection to use SqlConnection cnn = new SqlConnection(FHAVABorrower.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(FHAVABorrower.GetConnectionString(), "gsp_SelectFHAVABorrowersByFNMCreditReportScoreType"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@fNMCreditReportScoreType"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectFHAVABorrowersByFNMCreditReportScoreType", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(fHAVABorrowers, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(FHAVABorrowers fhavaborrowers, System.Data.SqlClient.SqlDataReader data) { // Do nothing if we have nothing if (data == null) { return; } // Create a local variable for the new instance. FHAVABorrower newobj = null; // Iterate through the data reader while (data.Read()) { // Create a new object instance newobj = System.Activator.CreateInstance(fhavaborrowers.ContainsType[0]) as FHAVABorrower; // Let the instance set its own members newobj.SetMembers(ref data); // Add the new object to the collection instance fhavaborrowers.Add(newobj); } }