HasMany Relationship Inside Matching

So, I have problems displaying problems in free nhibernate. I want to use join mapping to smooth the staging table: Here is my structure:

[Vehicle]
VehicleId
...

[DTVehicleValueRange]
VehicleId
DTVehicleValueRangeId
AverageValue
...

[DTValueRange]
DTVehicleValueRangeId
RangeMin
RangeMax
RangeValue

Please note that DTValueRange does not have a VehicleID. I want to flatten a DTVehicleValueRange into my Vehicle class. Tgis works fine for AverageValue, as it's just a value, but I can't get the ValueRange collection to display correctly.

    public VehicleMap()
    {
        Id(x => x.Id, "VehicleId");
        Join("DTVehicleValueRange", x =>
        {
            x.Optional();
            x.KeyColumn("VehicleId");
            x.Map(y => y.AverageValue).ReadOnly();
            x.HasMany(y => y.ValueRanges).KeyColumn("DTVehicleValueRangeId"); // This Guy
        });
    }

The HasMany mapping does not seem to do anything if it is inside Join. If it is outside Join and I specify the table, it displays, but nhibernate tries to use VehicleID, not DTVehicleValueRangeId.

What am I doing wrong?

+3
2

DTVehicleValueRange? (.. )?

, "--" Vehicle DTValueRange, , , , HasManyToMany.

0

. SQL , HasMany < > ParentThing, WorkThing ( , )

" " ref hasmany, .

public class ThingMap : ClassMap<WorkThingView> { 
     public ThingMap() {
                ReadOnly();
                Table("ParentThing");
                Id(x => x.ParentThingId);
                Map(x => x.ParentName);
                Join("WorkThing", join => {
                    join.KeyColumn("ParentThingId");
                    join.Map(m => m.FooCode);
                    join.Map(m => m.BarCode);
                    join.Map(x => x.WorkThingId);
                    join.HasMany(x => x.WorkThingCodes)
                        .Table("WorkThingCode").KeyColumn("WorkThingId").PropertyRef("WorkThingId")
                        .Element("WorkThingCode");
                });
            }
}
0

Source: https://habr.com/ru/post/1737532/


All Articles