我有这样的映射问题:
请注意,子实体(TimeSeriesValue)具有复合Id,并且没有对父(TimeSeries)的引用。
如果我有从TimeSeriesValue到TimeSeries的引用,我会将其映射为下面的snown。你能否提供一些想法如何在没有TimeSeriesValue.TimeSeries属性的情况下映射它(xml-mapping,fluent-mapping或者只是非常感谢)?
public class TimeSeries
{
public int Id { get; set; }
public IList<TimeSeriesValue> Values { get; set; }
public TimeSeries TimeSeries { get; set; }
}
public class TimeSeriesValue
{
public DateTime Time { get; set; }
public decimal Value { get; set; }
}
public class TimeSeriesMap : ClassMap< TimeSeries>
{
public TimeSeriesMap()
{
Not.LazyLoad();
Id(x => x.Id).GeneratedBy.Identity();
HasMany(x => x.Values)
.AsBag()
.Cascade.AllDeleteOrphan()
.Inverse()
.KeyColumn( "TimeSeriesId")
.ForeignKeyConstraintName( "FK_TimeSeriesId")
;
}
}
public class TimeSeriesValueMap : ClassMap< TimeSeriesValue>
{
public TimeSeriesValueMap()
{
Not.LazyLoad();
CompositeId()
.KeyReference(x => x.TimeSeries, "TimeSeriesId")
.KeyProperty(x => x.Time);
Map(x => x.Value);
}
}