2011-09-08 5 views
2

新しいLoquacious設定を使用してIDictionaryにマッピングする際に問題が発生しています。ここでNHibernate 3.2 IDictionaryによるマッピング

クラスです:

public class Person 
{ 
    public Person() 
    { 
     Description = new Dictionary<int, string>(); 
    } 

    public virtual int Id { get; set; } 

    // can be in various languages 
    public virtual IDictionary<int, string> Resources { get; set; } 
} 

public class PersonResource 
{ 
    public virtual string Description { get; set; } 
} 

ここでのマッピングです:

public class TestPersonMap : ClassMapping<TestPerson> 
{ 
    Table("TestPersons"); 

    Id(c => c.Id, m => m.Generator(Generators.HighLow, gm => gm.Params(new { max_low = 1000 }))); 

    Map(c => c.Resources, mpm => 
           { 
         mpm.Table("TestPersonResources"); 
         mpm.Key(km => km.Column("Id")); 
        }, 
      mkr => mkr.Component(cem => cem.Property(p => p.Description))); 

これは、このようなデータベース内のテーブルを生成します。

TestPersons 
----------- 
Id 

TestPersonResources 
------------------- 
Id 
Description 
idx 

質問は、私がどのように、ありますTestPersonResourcesテーブルの 'idx'列の名前をLcidに変更しますか?

私は、この例でhttp://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm.UsageExamples/ComponentAsDictionaryKey/Demo.cs

を探してみましたしかし、私は私の問題に適用するように見えることはできません。

ありがとうございます!

答えて

2

NHibernateのソースコードを使いこなしてみると、最終的にはうまくいきました。ここに私がしたことがあります:

Map(c => c.Resources, mpm => 
          { 
        mpm.Key(km => km.Column("Id")); 
        mpm.Table("TestPersonResources"); 
       }, 
      mkr => mkr.Element(mkm => mkm.Column("Lcid")), 
      cer => cer.Component(cem => cem.Property(p => p.Description, pm => pm.Length(100)))); 
+0

これは私が必要としたものでした。私の人生の時間を少なくとも節約しました:-) – Dav

関連する問題