Example #1
0
        internal IQueryable <ListProduct> GetProducts(PredicateObject predicateObject)
        {
            string nameFilter = GetNameFilter(predicateObject);

            var products = AdventureWorks.Products
                           .Join(AdventureWorks.ProductProductPhotoes,
                                 x => x.ProductID,
                                 y => y.ProductID,
                                 (x, y) => new { x, y })
                           .Join(AdventureWorks.ProductPhotoes,
                                 a => a.y.ProductPhotoID,
                                 b => b.ProductPhotoID,
                                 (a, b) => new { a, b })
                           .Where(
                product => product.a.x.Name != null &&
                product.a.x.ListPrice > 0 &&
                product.a.x.StandardCost > 0 &&
                product.b.ThumbNailPhoto != null &&
                product.b.LargePhoto != null &&
                !product.b.ThumbnailPhotoFileName.Contains(NoImageString) &&
                !product.b.LargePhotoFileName.Contains(NoImageString) &&
                (nameFilter == "" || product.a.x.Name.Contains(nameFilter)))
                           .OrderBy(product => product.a.x.Name)
                           .Skip(predicateObject.Skip)
                           .Take(predicateObject.Take)
                           .Select(product => new ListProduct()
            {
                ProductID                = product.a.x.ProductID,
                Name                     = product.a.x.Name,
                StandardCost             = product.a.x.StandardCost,
                ListPrice                = product.a.x.ListPrice,
                ProductSubcategoryID     = product.a.x.ProductSubcategoryID,
                SellStartDate            = product.a.x.SellStartDate,
                ProductThumbnail         = product.b.ThumbNailPhoto,
                ProductThumbnailFileName = product.b.ThumbnailPhotoFileName
            });

            return(products);
        }
Example #2
0
        internal int GetProductCount(PredicateObject predicateObject)
        {
            string nameFilter = GetNameFilter(predicateObject);

            return(AdventureWorks.Products
                   .Join(AdventureWorks.ProductProductPhotoes,
                         x => x.ProductID,
                         y => y.ProductID,
                         (x, y) => new { x, y })
                   .Join(
                       AdventureWorks.ProductPhotoes,
                       a => a.y.ProductPhotoID,
                       b => b.ProductPhotoID,
                       (a, b) => new { a, b })
                   .Count(product => product.a.x.Name != null &&
                          product.a.x.ListPrice > 0 &&
                          product.a.x.StandardCost > 0 &&
                          product.b.ThumbNailPhoto != null &&
                          product.b.LargePhoto != null &&
                          !product.b.ThumbnailPhotoFileName.Contains(NoImageString) &&
                          !product.b.LargePhotoFileName.Contains(NoImageString) &&
                          (nameFilter == "" || product.a.x.Name.Contains(nameFilter))));
        }
Example #3
0
 private string GetNameFilter(PredicateObject predicateObject)
 {
     return(predicateObject.WhereObjects.Any()
                         ? predicateObject.WhereObjects.First().ComparisonValue
                         : "");
 }