我有一个复杂的实体,有两个一对多的集合,我想更新它们我该怎么做?
Here is my mapping:
internal sealed class LeadMap : ClassMap<Lead> {
public LeadMap() {
Id(x => x.Id).GeneratedBy.Identity().Column("Id");
Map(x => x.Notes, "Notes");
Map(x => x.Source, "Source");
Map(x => x.BusinessName, "BusinessName");
Map(x => x.Telephone, "Telephone");
Map(x => x.UpdateDate, "UpdateDate");
Map(x => x.ConversationDate, "ConversationDate");
Map(x => x.IsConverted, "IsConverted");
Map(x => x.InsertDate, "InsertDate").Generated.Insert();
// contact details mapping
Component(x => x.ContactDetails, contact => {
contact.Map(x => x.Name, "ContactName");
contact.Map(x => x.Email, "ContactEmail");
contact.Map(x => x.Telephone, "ContactTelephone");
});
// City: 1 : 1
References(x => x.City).LazyLoad().Column("CityId");
// MeetingEvent: 1 : 1
References(x => x.MeetingEvent).LazyLoad().Column("MeetingEventId").Cascade.All();
// Agent: 1 : 1
References(x => x.Agent).LazyLoad().Column("AgentId");
// AutoStatus: 1 : 1
References(x => x.AutoStatus).LazyLoad().Column("AutoStatusId");
// ManagementStatus: 1 : 1
References(x => x.ManagementStatus).LazyLoad().Column("ManagementStatusId").Cascade.All();
// Activities: * : *
HasManyToMany(x => x.Activities)
.Cascade
.All()
.LazyLoad()
.NotFound.Ignore()
.ParentKeyColumn("LeadId")
.ChildKeyColumn("ActivityId")
.Table("LeadsToActivities");
// Areas: * : *
HasManyToMany(x => x.Areas)
.Cascade
.All()
.LazyLoad()
.NotFound.Ignore()
.ParentKeyColumn("LeadId")
.ChildKeyColumn("AreaId")
.Table("LeadToAreas");
Table("Leads");
}
}
public sealed class LeadsToActivitiesMap : ClassMap<LeadsToActivities> {
public LeadsToActivitiesMap() {
Id(x => x.Id).GeneratedBy.Identity().Column("Id");
Map(x => x.ActivityId, "ActivityId");
Map(x => x.LeadId, "LeadId");
Table("LeadsToActivities");
}
}
public sealed class AreasToLeadsMap : ClassMap<AreasToLeads> {
public AreasToLeadsMap() {
Id(x => x.Id).GeneratedBy.Identity().Column("Id");
Map(x => x.AreaId, "AreaId");
Map(x => x.LeadId, "LeadId");
Table("LeadToAreas");
}
}
实际上它忽略了我的更新,我做错了什么?