public static ProductDigitalGoodCollection LoadForVariant(int productId, string optionList, int maximumRows, int startRowIndex, string sortExpression)
        {
            bool variantSpecified = !string.IsNullOrEmpty(optionList);
            //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(" " + ProductDigitalGood.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_ProductDigitalGoods");
            selectQuery.Append(" WHERE ProductId = @productId");
            if (variantSpecified)
            {
                selectQuery.Append(" AND OptionList = @optionList");
            }
            else
            {
                selectQuery.Append(" AND OptionList IS NULL");
            }
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@productId", System.Data.DbType.Int32, productId);
            if (variantSpecified)
            {
                database.AddInParameter(selectCommand, "@optionList", System.Data.DbType.String, optionList);
            }
            //EXECUTE THE COMMAND
            ProductDigitalGoodCollection results = new ProductDigitalGoodCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        ProductDigitalGood digitalGood = new ProductDigitalGood();
                        ProductDigitalGood.LoadDataReader(digitalGood, dr);
                        results.Add(digitalGood);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
        public static ProductDigitalGoodCollection  LoadForCriteria(string sqlCriteria, 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(" " + ProductDigitalGood.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_ProductDigitalGoods");
            string whereClause = string.IsNullOrEmpty(sqlCriteria) ? string.Empty : " WHERE " + sqlCriteria;

            selectQuery.Append(whereClause);
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());
            //EXECUTE THE COMMAND
            ProductDigitalGoodCollection results = new ProductDigitalGoodCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        ProductDigitalGood productDigitalGood = new ProductDigitalGood();
                        ProductDigitalGood.LoadDataReader(productDigitalGood, dr);
                        results.Add(productDigitalGood);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }