tags:

views:

39

answers:

1

I have the following set of tables in an existing database.

Resource - ResourceID

LocalisedResource - LocalisedResourceID, ResourceID, Language, Culture, LocalisedTerm

Office - OfficeId, NameResourceId

Now I wan to query for a particular office and get back the office's name for a particular language culture combination falling back to a default language of "EN" and culture of "GB" if no entry is found for the language and culture specified.

So, something like this...

public class Office
{
    public virtual int OfficeId { get; set; }
    public string Name { get; set; }        
}

repository.GetOffice(5 /* id */,"zh" /* language */,"cht" /* culture */);

We also want to do it for saving too...

repository.SaveOffice(office,"zh" /* language */,"cht" /* culture */);

At the moment we are doing all of our mapping in a custom written set of stored procedures using a function to pull out the correct name. This is obviously slowing us down as we have to write a lot of SPs for all our crud code.

+1  A: 

This article on localizing NHibernate using filters might help with retrieving your object, but I don't know if it will help with saving.

Edited to add: You could map the localasied names as a collection on Office, and use a method on OFfice to lookup the localised name from the collection. Performance might be acceptable depending on how your application uses the Office object.

Jamie Ide
Excellent, gives me a starting point on where to go next. I'll leave it unanswered for now to see if anyone can solve the save but will mark as the best answer in a couple of days if not.
Chris Meek