我在使用新的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?
但我似乎无法将其应用于我的问题。
提前致谢!
答案 0 :(得分: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))));