Please try the following:
EntityCollection<ProductEntity> products = new EntityCollection<ProductEntity>();
RelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(ProductFields.ProductCategoryId == 1);
using (DataAccessAdapter productsAdapter = DataAccess.AdaptorFactory.GetNewAdaptor(true))
{
productsAdapter.FetchEntityCollection(products, bucket);
}
return products;
The issue is: you have filtered on a field in a related entity, without specifying the rlation to it (Join).
But anyway I think in your case you don't need the ProductCategory Entity. As you have the CategoryId in the Product Entity.
But for the sake of demonstrating here how it would look like:
EntityCollection<ProductEntity> products = new EntityCollection<ProductEntity>();
RelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(ProductCategoryFields.ProductCategoryId == 1);
bucket.Relations(ProductEnity.Relations.ProductCategoryEntity);
using (DataAccessAdapter productsAdapter = DataAccess.AdaptorFactory.GetNewAdaptor(true))
{
productsAdapter.FetchEntityCollection(products, bucket);
}
return products;