Udi just posted about this topic. http://www.udidahan.com/2009/01/24/ddd-many-to-many-object-relational-mapping/
On Feb 9, 3:39 pm, Dom <[email protected]> wrote: > Thank you for your advice. > I'll try this solution just to get it work. Just for my enlightment, > do you have a rationale for not using many-to-many? > > Thinking about it I am wondering if the problem does not come from the > weird relationship from ShipmentOnTrip to shipment (kind of a many-to- > many between ShipmentOnTrip and Shipments) due to the fact that the > line No1 is bearing more information than the other one. > It might be easier to map the table Shipments as 2 classes > a Shipment ( where LineNo = 1) has many ShipmentCost (a projection of > the Shipment table). > > Using the "where lineNo=1" suppress the problems with using the many- > to-many. > > -- > Dom > > On 9 Feb, 20:53, Will Shaver <[email protected]> wrote: > > > I'd recommend using two one-to-many relationships with a class in > > between. Annoying for modeling, but you can make the collections > > protected and publish public collections on your objects. > > > public class Trips > > { > > public Trips() { > > ShipmentsOnTrip = new List<ShipmentsOnTrip>(); > > } > > > protected virtual IList<ShipmentsOnTrip> ShipmentsOnTrip {get;set;} > > > public virtual Shipments[] GetShipments() > > { > > return (from c in ShipmentsOnTrip select > > c.Shipment).ToArray(); > > } > > > } > > > etc > > > On Mon, Feb 9, 2009 at 10:01 AM, Dom <[email protected]> wrote: > > > > Hi, > > > I don´t manage to sort out the mapping of my classes and would > > > appreciate some guidance. > > > I have 3 tables > > > Trips (tripId PK) > > > ShipmentsOnTrip(tripID, ShipmentId) , PK is composite of both > > > Shipments(shipmentId, lineNo) PK is composite of both, lineNo=1 is > > > like the main shipment record but their might be others (the parent > > > info are on no 1 but this is irrelevant here) > > > Shipment is mapped with a composite-id. > > > I am trying to map a Trip.Shipments as a many-to-many relationship but > > > I don´t manage to express it. I tried variations of the following: > > > <key-column name = tripId> > > > <many-to-many class = shipment> > > > <column name = shipmentID /> > > > <column name = lineNo /> <-- will crash without (missing > > > column on pk) and with when trying to join. > > > </many..> > > > > (I might need to rework my model with the lineNo = 1 being a class > > > holding som childs but that is another problem :) ) > > > > Thanks for any pointer in direction of the solution. > > > -- > > > Dom --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
