[英]Fluent NHibernate with Key/Value Column Relation
I'm trying to create a table that will work as additional data for another table. 我正在尝试创建一个表,该表将用作另一个表的其他数据。
For example I have my main table called Person . 例如,我有一个名为Person的主表。 This table will contain zero or many dynamic records (Free text key and free text value) from a table called PersonDynamicInfo .
该表将包含零个或多个来自称为PersonDynamicInfo的表的动态记录(自由文本键和自由文本值)。
public PersonMap(){ Id(x => x.Id); 公共PersonMap(){Id(x => x.Id); Table("Person");
Table(“ Person”); Map(x => x.Name);
Map(x => x.Name);
HasMany(x => x.PersonDynamicInfo) .KeyColumn("Id") .Access.CamelCaseField(Prefix.Underscore) .AsSet() .Cascade.AllDeleteOrphan() .Not.KeyNullable(); HasMany(x => x.PersonDynamicInfo).KeyColumn(“ Id”).Access.CamelCaseField(Prefix.Underscore).AsSet().Cascade.AllDeleteOrphan().Not.KeyNullable(); }
}
public PersonDynamicInfo(){ Id(x => x.Id); 公共PersonDynamicInfo(){Id(x => x.Id); Table("PersonDynamicInfo");
Table(“ PersonDynamicInfo”); Map(x => x.Key);
Map(x => x.Key);
Map(x => x.Value); 映射(x => x.Value); }
}
What I want to achieve is the following: 我要实现以下目标:
Is there way I can achieve this without manually deleting the unused records on PersonDynamicInfo? 有没有我可以手动删除PersonDynamicInfo上未使用的记录的方法?
Many thanks! 非常感谢!
I think what you need is a reference to the Person
in your PersonDynamicInfo
mapping: 我认为您需要的是在
PersonDynamicInfo
映射中对Person
的引用:
public PersonDynamicInfo(){
Id(x => x.Id);
Table("PersonDynamicInfo");
Map(x => x.Key);
Map(x => x.Value);
References(x => x.Person, "PersonId").Cascade.All();
}
I may have misunderstood your question, however. 但是,我可能误解了您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.