public static ProductCollection GetProductsInOrder(int orderNumber) { ProductCollection allProductsTemp = new ProductCollection(); ProductCollection allProducts = new ProductCollection(); using (FreeMarketEntities db = new FreeMarketEntities()) { allProductsTemp.Products = db.GetAllProductsInOrder(orderNumber) .Select(c => new Product { Activated = c.Activated, DateAdded = c.DateAdded, DateModified = c.DateModified, DepartmentName = c.DepartmentName, DepartmentNumber = c.DepartmentNumber, Description = c.Description, LongDescription = c.LongDescription, PricePerUnit = c.PricePerUnit, ProductNumber = c.ProductNumberID, Size = "", SupplierName = c.SupplierName, SupplierNumber = c.SupplierNumberID, Weight = 0, ProductRating = c.ProductRating ?? 0, ProductReviewText = c.ProductReviewText, PriceRating = c.PriceRating ?? 0, ReviewId = c.ReviewId, PriceOrder = c.Price, IsVirtual = c.IsVirtual } ).ToList(); allProducts.Products = allProductsTemp.Products .DistinctBy(c => new { c.ProductNumber, c.SupplierNumber }) .ToList(); SetProductData(allProducts); return(allProducts); } }