NHibernate 3.2 通过代码映射 IDictionary
我在使用新的 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?
但我不能似乎将其应用于我的问题。
提前致谢!
I'm having a problem mapping to IDictionary using the new Loquacious configuration.
Here's the class:
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; }
}
Here's the mapping:
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)));
This produces a table in the database like this:
TestPersons
-----------
Id
TestPersonResources
-------------------
Id
Description
idx
The question is, how do I change the name of the 'idx' column in the TestPersonResources table to Lcid?
I tried looking at this example http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm.UsageExamples/ComponentAsDictionaryKey/Demo.cs
But I can't seem to apply it to my problem.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番折腾并仔细研究 NHibernate 源代码后,我想我终于让它工作了。这就是我所做的:
After messing around and looking harder at the NHibernate source code, I think I finally got it working. Here's what I did: