Thanks Fabio, I already read that article and it's a very interesting
approach and effectively uses <map> of <component> but maps by entity
id as the key column and works well if you have only one localizable
field but I can't see how to map several fields. For example (not real
code):

class Document {
    public virtual Guid Id { get; set; }
    public virtual string Code { get; set; }
    public virtual LocalizableString Title { get; set; }
    public virtual LocalizableString Description { get; set; }
}

I should find the localized string in the strings table through the
Document.Id as well as the field name, a string column value like
"document_name" or "document_title" in order to find the right
translation. I there any way to do that using NHibernate?

On 4 mar, 15:07, Fabio Maulo <[email protected]> wrote:
> <map> of <component> instead of <element> ?
>
> 2010/3/4 Marc Climent <[email protected]>
>
>
>
> > The thing is not the ordering, but how to associate the field with
> > it's translation using Nhibernate.
>
> > On 4 mar, 13:02, cliff vaughn <[email protected]> wrote:
> > > have you tried just using the "order", or "orderby" property in your
> > mapping
> > > for the list?
>
> > > On Thu, Mar 4, 2010 at 5:49 AM, Marc Climent <[email protected]>
> > wrote:
> > > > I have found some articles about this particular subject but they do
> > > > not solve what I want to achieve and I ran out of ideas.
>
> > > > Right now I have a kind of localizable field which is is stored like
> > > > in <a href="http://fabiomaulo.blogspot.com/2009/06/localized-property-
> > > > with-nhibernate.html<
> >http://fabiomaulo.blogspot.com/2009/06/localized-property-with-nhiber..
> > .>">this
> > > > article</a>, using a UserType that
> > > > serializes itself to a database field. This solution has worked for
> > > > months but now a list must be sorted by a field of this type and the
> > > > table contains a lot of rows, so sorting by this field forces us to
> > > > retrieve all the entities on the table to get the value of the
> > > > localizable string and sort them. That's pretty inefficient.
>
> > > > Another complexity is that an entity can have several of this
> > > > localizable properties so my idea was to create a couple of tables,
> > > > one containing the reference to the entity and the field and the other
> > > > containing the values for each particular language:
>
> > > > Dictionary           |dict_id|entity_id|entity_field_name|
> > > > DictionaryValues |dict_id|locale_id|value|
>
> > > > This table structure can be mostly achieved as explained in <a
> > > > href="http://www.webdevbros.net/2009/06/24/create-a-multi-languaged-
> > > > domain-model-with-nhibernate-and-c/<
> >http://www.webdevbros.net/2009/06/24/create-a-multi-languaged-domain-..
> > .>">this
> > > > other article</a>, but now I
> > > > need to establish the link with the entity id and the entity field and
> > > > I don't know how to do it using NHibernate in an elegant way (i.e.
> > > > getting automatically the field name and looking for the right
> > > > entity_field_name in the Dictionary table and not having to specify
> > > > the current culture id but getting it from the current Thread).
>
> > > > So, the thing becomes quite challenging for me right now and I'm sure
> > > > that some solution can be found with some help.
>
> > > > Any idea? (I promise a post on my blog whenever I find a good
> > > > solution).
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > --
> > > thanks
>
> > > cliff
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Fabio Maulo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to