2

我在使用新的 Loquacious 配置映射到 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

但我似乎无法将其应用于我的问题。

提前致谢!

4

1 回答 1

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))));
于 2011-09-10T08:37:48.260 回答