Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ayendes post is a great start how it should be designed.</p> <p>It will perfectly work for enterprise solutions. The names in a separate table is like any other list of values. The special thing is, that it is filtered in the mapping.</p> <p>Edit - Options:</p> <p><strong>Use another entity to edit the data</strong></p> <p>There is Product entity that has all the names as list. LocalizedProduct has only the current languages name.</p> <p>Get the filtered entity </p> <ul> <li>by either mapping it as described in the blog, with the filter.</li> <li>by selecting it with a result transformer (Transformers.AliasToBean) or with 'select new LocalizedProduct(id, name, prize ...)'. LocalizedProduct would not be mapped in this case. Should be second-level-cache-friendly.</li> </ul> <p>If you have many references to Product, it is probably not so nice to have two classes, because you don't know which class the reference should have.</p> <p><strong>Use the same entity for editing and displaying</strong></p> <pre><code>class Product { string LocalizedName { get { return AllProductNames[Thread.CurrentThread.CurrentCulture.LCID]; } } IDictionary&lt;int, string&gt; AllProductNames { get; private set; } } </code></pre> <p>There are properties for a localized product name (get) <em>and</em> all product names.</p> <ul> <li>don't filter them at all :-) There is a bit of network overhead. if you have only 3 to 5 languages, it is not so bad. if you have 20 or more, it's probably better to filter the names.</li> <li>use a (optional) filter as described in the blog, but on the product names</li> <li>use a (optional) ResultTransformer (CriteriaUtil.AliasToEntityMap) to filter the names.</li> </ul> <p>To be honest, I would choose a option that dies not need filters in the mapping files. Filters belong to queries where they are more maintainable.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload