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 . This table will contain zero or many dynamic records (Free text key and free text value) from a table called PersonDynamicInfo .
public PersonMap(){ Id(x => x.Id); Table("Person"); Map(x => x.Name);
HasMany(x => x.PersonDynamicInfo) .KeyColumn("Id") .Access.CamelCaseField(Prefix.Underscore) .AsSet() .Cascade.AllDeleteOrphan() .Not.KeyNullable(); }
public PersonDynamicInfo(){ Id(x => x.Id); Table("PersonDynamicInfo"); Map(x => x.Key);
Map(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?
Many thanks!
I think what you need is a reference to the Person
in your PersonDynamicInfo
mapping:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.