All works great but some products are returned multiple times. This is the query I've built:
public virtual IPagedList<Product> GetAllProductsWithDiscount(int languageId, int pageIndex, int pageSize)
{
var query = from p in _productRepository.Table
from pv in p.ProductVariants.DefaultIfEmpty()
from pc in p.ProductCategories
where pv.OldPrice != 0
&& pv.OldPrice != pv.Price
&& p.Deleted == false
&& (pv.AvailableEndDateTimeUtc == null
|| pv.AvailableEndDateTimeUtc > DateTime.Now)
&& pv.Published == true
orderby pc.CategoryId
select p;
var products = new PagedList<Product>(query, pageIndex, pageSize);
return products;
}
I simply cannot figure out why if I remove the join with ProductCategories all works nice but as it is now, it has the issue described above.
Is there anybody here who can help me with this?
thanks in advance,