/// <summary> /// Loads a collection of Product objects from the database. /// </summary> /// <returns>A collection containing all of the Product objects in the database.</returns> public static ProductCollection LoadCollection(string spName, SqlParameter[] parms) { ProductCollection result = new ProductCollection(); using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms)) { while (reader.Read()) { Product tmp = new Product(); tmp.LoadFromReader(reader); result.Add(tmp); } } return(result); }
/// <summary> /// Loads a Product object from the database using the given where clause /// </summary> /// <param name="whereClause">The filter expression for the query</param> /// <returns>A Product object</returns> public static Product LoadWhere(string whereClause) { SqlParameter[] parameterValues = new SqlParameter[] { new SqlParameter("@WhereClause", whereClause) }; using (SqlDataReader reader = SqlHelper.Default.ExecuteReader("spProduct_SelAll", parameterValues)) { if (reader.Read()) { Product result = new Product(); result.LoadFromReader(reader); return(result); } else { return(null); } } }
/// <summary> /// Loads a Product object from the database using the given ProductId /// </summary> /// <param name="productId">The primary key value</param> /// <returns>A Product object</returns> public static Product Load(Guid productId) { SqlParameter[] parameterValues = new SqlParameter[] { new SqlParameter("@ProductId", productId) }; using (SqlDataReader reader = SqlHelper.Default.ExecuteReader("spProduct_SelRec", parameterValues)) { if (reader.Read()) { Product result = new Product(); result.LoadFromReader(reader); return(result); } else { return(null); } } }