コード例 #1
0
    /// <summary>
    /// Gets a product and all of it's subcollections (images, promos, etc)
    /// </summary>
    public static Commerce.Common.Product GetProductDeep(int productID)
    {
        //load up the product using a multi-return DataSet
        //for performance, queue up the 4 SQL calls into one
        string sql = "";

        //Product Main Info
        Query q = new Query("vwProduct");

        q.AddWhere("productID", productID);

        //append
        sql += q.GetSql() + "\r\n";

        //Images
        q = new Query(Commerce.Common.Image.GetTableSchema());
        q.AddWhere("productID", productID);
        q.OrderBy = OrderBy.Asc("listOrder");
        //append
        sql += q.GetSql() + "\r\n";

        //Reviews
        q = new Query(ProductReview.GetTableSchema());
        q.AddWhere("productID", productID);
        q.AddWhere("isApproved", 1);

        //append
        sql += q.GetSql() + "\r\n";


        //Descriptors
        q = new Query(ProductDescriptor.GetTableSchema());
        q.AddWhere("productID", productID);
        q.OrderBy = OrderBy.Asc("listOrder");


        //append
        sql += q.GetSql() + "\r\n";

        QueryCommand cmd = new QueryCommand(sql);

        cmd.AddParameter("@productID", productID, DbType.Int32);
        cmd.AddParameter("@isApproved", true, DbType.Boolean);
        DataSet ds = DataService.GetDataSet(cmd);


        Product product = new Product();

        LoadByDataSet(product, ds);
        return(product);
    }