public IList<Product> GetProducts(string productName, ProductCategory category, int pageSize, int pageNumber) { int categoryId = category.ProductCategoryID; IEnumerable<Product> products = this.context.Execute<Product>(new Uri(this.context.BaseUri.ToString() + "/ProductCategory(" + categoryId + ")/Product?$filter=indexof(Name,'" + productName + "') gt -1 or '' eq '" + productName + "'&$top=" + pageSize + "&$skip=" + pageSize * pageNumber)); List<Product> productsSet = new List<Product>(); foreach (Product p in products) { this.context.LoadProperty(p, "ProductCategory"); productsSet.Add(p); } return productsSet; }
public int GetProductsCount(string productName, ProductCategory category) { var query = (DataServiceQuery<Product>) (from p in this.context.CreateQuery<Product>("Product") where ((p.Name.IndexOf(productName) > -1 || string.IsNullOrEmpty(productName)) && p.ProductCategory.ProductCategoryID == category.ProductCategoryID) select p); return query.Count(); }
public IList<Product> GetProducts(string productName, ProductCategory category) { return null; }