Hi, i'm using selfservicing and have a general implementation question.
i have essentialy these tables.
product
productid
productprice
producttext
productid
languageid
description
header
language
languageid
languagename
when a product is entered a producttext is automaticaly created in a (required) main language.
the products and text are entered by our customers, and every product can have multiple text entries in different languages. But when viewing the data in a certain langauge we have to ensure that they SEE text so if the requested language is not entered in the producttext table then i want to ensure that they get the (required) main language.
After we have to show a list of 200+ products, our current code is too slow. it simply runs though products and creates a producttext entity, checks on its state is loaded or not, and if not then grabs the other. this means that there could be 400 querys reading producttext while looping though 200 items.
I'd like to prefetch the producttext when getting the products, but not all languages, just the requested language or the required language if the requested is not present in the database.
the following query gets the productid and the language to use, that could be used in a subquery to get the result, but i'm having a real problem implementing this though llbgen-selfservicing code.
SELECT ProductId, ISNULL(ProductText.LanguageId,2) AS LanguageId
FROM
Product LEFT OUTER JOIN
ProductText ON
((Product.ProductId = ProductText.ProductId) AND
(ProductText.LanguageId = 4))
2 is the required text that is guaranteed to be in the database, and 4 is the requested language.