FluentNHibernate IDctionary 具有多对多关系
我有一个以这种方式构建的映射: public class Person
{
public IDictionary<bool, Action> Actions { get; set; }
}
public class Action
{
public string Name { get; set; }
}
// Map for Person
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.Id) ...
Map(x => x.Name) ...
Table("Persons")
}
}
// Map for Action
public class ActionMap : ActionMap<Action>
{
public ActionMap()
{
Id(x => x.Id) ...
Map(x => x.Name) ...
Table("Actions")
}
}
我现在需要做的是这个。 我需要第三个表,其中包含以下字段:
PersonId 动作ID 对/错
因为我在类 person 中有操作集合,所以我正在考虑使用多个,但我找不到有关如何映射 IDictionary 的文档。 有什么想法吗?错误的做法?
I have a mapping structured in this way:
public class Person
{
public IDictionary<bool, Action> Actions { get; set; }
}
public class Action
{
public string Name { get; set; }
}
// Map for Person
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.Id) ...
Map(x => x.Name) ...
Table("Persons")
}
}
// Map for Action
public class ActionMap : ActionMap<Action>
{
public ActionMap()
{
Id(x => x.Id) ...
Map(x => x.Name) ...
Table("Actions")
}
}
What I need to do now is this.
I need a third table that will contains this fields:
PersonId
ActionId
True/false
Because I have the collection of actions inside the class person i was thinking about using a manytomany, but I can't find documentation on how to map an IDictionary.
Any idea? Wrong approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道您是否已经找到了解决方案,但最近有一个更新(仅几周前),您可以简单地将其映射为
HasManyToMany(x => x.NameOfDictionary)
所以您可能想要更新您的 FNH。我还没有尝试过,但这里是链接:邮件列表帖子
Dunno if you've already found the solution but there's been a recent update(only a couple weeks ago) where you could simply map it as
HasManyToMany(x => x.NameOfDictionary)
so you might want to update your FNH.I haven't tried it yet though but here's the link: mailing list post