Hi there
(LLBLGen 2.6, adapter)
I have a simple shop solution that consists of the following entities:
- ProductEntity
- OrderEntity
- OrderedProductEntity
...accordingly, there is an m:n relation between products and orders through the OrderedProduct entity.
I need to aggregate order data from a product's perspective in order to do some simple analysis. For this, I created a simple TypedList, that provides the following information:
- ProductId (GROUPBY)
- OrderStatus (GROUPBY)
- Total ordered products: SUM(OrderedProduct.Quantity)
Now, I want to filter my products based on fourth table that provides localized product names (several per product), in order to do something like this before aggregating:
SELECT [...] from Products INNER JOIN OrderedProducts [...]
WHERE ProductId IN (
SELECT ProductId from ProductLocalization WHERE ProductName = "Lenovo Thinkpad T61"
)
However, in order to define a predicate to filter in the ProductLocalization table, I need to add a relation to my RelationPredicateBucket:
IRelationPredicateBucket filter = myTypeList.GetRelationInfo(); filter.Relations.Add(ShopProductEntity.Relations.ProductLocalizationEntityUsingProductId);
Now this is a problem: As soon as I add this relationship (without even specifying a filter), LLBLGen retrieves duplicates for my TypedList which results in wrong aggregates. I have currently three translations defined, so this is my result for a product "17" before and after having added the relation:
BEFORE: row.ProductId = 17, Quantities: 102
AFTER: row.ProductId = 17, Quantities: 306
How can I prevent this?
Thanks for your advice
Philipp