Exemple #1
0
        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);
        }
Exemple #2
0
 public static SaveResult Insert(ProductReview productReview)
 {
     return(productReview.Save());
 }
Exemple #3
0
 public static SaveResult Update(ProductReview productReview)
 {
     return(productReview.Save());
 }
Exemple #4
0
 public static bool Delete(ProductReview productReview)
 {
     return(productReview.Delete());
 }