/// <summary> /// Gets a related product collection by product identifier /// </summary> /// <param name="ProductID1">The first product identifier</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Related product collection</returns> public override DBRelatedProductCollection GetRelatedProductsByProductID1Paged(int ProductID1, bool showHidden, int PageIndex, int PageSize, ref int TotalRecords) { DBRelatedProductCollection relatedProductCollection = new DBRelatedProductCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_RelatedProductLoadByProductID1Paged"); db.AddInParameter(dbCommand, "ProductID1", DbType.Int32, ProductID1); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); db.AddInParameter(dbCommand, "PageIndex", DbType.Int32, PageIndex); db.AddInParameter(dbCommand, "PageSize", DbType.Int32, PageSize); db.AddOutParameter(dbCommand, "TotalRecords", DbType.Int32, 0); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBRelatedProduct relatedProduct = GetRelatedProductFromReader(dataReader); relatedProductCollection.Add(relatedProduct); } } TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords")); return relatedProductCollection; }
private static RelatedProductCollection DBMapping(DBRelatedProductCollection dbCollection) { if (dbCollection == null) return null; RelatedProductCollection collection = new RelatedProductCollection(); foreach (DBRelatedProduct dbItem in dbCollection) { RelatedProduct item = DBMapping(dbItem); collection.Add(item); } return collection; }
/// <summary> /// Gets a related product collection by product identifier /// </summary> /// <param name="ProductID1">The first product identifier</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Related product collection</returns> public override DBRelatedProductCollection GetRelatedProductsByProductID1(int ProductID1, bool showHidden) { DBRelatedProductCollection relatedProductCollection = new DBRelatedProductCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_RelatedProductLoadByProductID1"); db.AddInParameter(dbCommand, "ProductID1", DbType.Int32, ProductID1); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBRelatedProduct relatedProduct = GetRelatedProductFromReader(dataReader); relatedProductCollection.Add(relatedProduct); } } return relatedProductCollection; }