You can do it using <map>
btw in NH what you map are classesToDb
you wrote

// Swedish

string swedish = randomEntity.Word.WordTranslations.First(x =>
x.Language.Code == “sv-SE”);



but the class RandomEntity does not have a relation with the class Word.

2010/4/7 Kim Johansson <[email protected]>

>  Hello dear NH users!
>
>
>
> I have the following tables:
>
>
>
> Table Word
>
> {
>
>   Id
>
> }
>
>
>
> Table WordTranslation
>
> {
>
>   Id
>
>   LanguageId
>
>   Value
>
> }
>
>
>
> Table Language
>
> {
>
>   Id
>
>   Code
>
> }
>
>
>
> Table RandomEntity
>
> {
>
>   Id
>
>   WordId
>
> }
>
>
>
> I kinda want the following object-model:
>
>
>
> class RandomEntity
>
> {
>
>   public virtual string Id { get; set; }
>
>   public virtual Dictionary<string, string> Translations { get; set; }
>
> }
>
>
>
> That should map Translations to the WordId, then get all the
> WordTranslations, let the Key be Language.Code and Value be
> WordTranslation.Value.
>
>
>
> So I could do stuff like: RandomEntity randomEntity =
> session.Get<RandomEntity>(15);
>
>
>
> // Swedish translation
>
> string swedish = randomEntity.Translations[“sv-SE”];
>
>
>
> // English
>
> string english = randomEntity.Translations[“en-US”];
>
>
>
> // French
>
> string french = randomEntity.Translations[“fr-FR”];
>
>
>
> Right now we got it modeled in Entity Framework and we access a specific
> translation like this:
>
> RandomEntity randomEntity = dataContext.RandomEntities.First(x => x.Id ==
> 15);
>
>
>
> // Swedish
>
> string swedish = randomEntity.Word.WordTranslations.First(x =>
> x.Language.Code == “sv-SE”);
>
>
>
> A shitload more to write…
>
>
>
> I’m just wondering, is it possible to map the way I want it and what should
> I look into?
>
> Using NH 3.0…
>
>
>
> Med vänliga hälsningar,
> Kim Johansson
>
> *Industritorget Sweden AB***
>
> Söndrumsvägen 29
> 302 39 Halmstad
>
> tel:  035 - 260 32 00
> fax: 035 - 12 24 83
>
> epost: *[email protected] <[email protected]>*
> webb: http://www.industritorget.se
>
> [image: 
> http://www.industritorget.se/admin/pics/startbil1.jpg]<http://www.industritorget.se/>
>
>
>
>
>
> --
> 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.

<<image001.jpg>>

Reply via email to