public static ProductReviewCollection LoadForReviewerProfile(Int32 reviewerProfileId, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + ProductReview.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_ProductReviews"); selectQuery.Append(" WHERE ReviewerProfileId = @reviewerProfileId"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@reviewerProfileId", System.Data.DbType.Int32, reviewerProfileId); //EXECUTE THE COMMAND ProductReviewCollection results = new ProductReviewCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { ProductReview productReview = new ProductReview(); ProductReview.LoadDataReader(productReview, dr); results.Add(productReview); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
public static SaveResult Insert(ProductReview productReview) { return(productReview.Save()); }
public static SaveResult Update(ProductReview productReview) { return(productReview.Save()); }
public static bool Delete(ProductReview productReview) { return(productReview.Delete()); }