Good timing Jason, the post helped me solve my problem by rethinking about the real problem and not focusing on the technical one :)
As I stated above I am only interested in a one of the one-to-many side but because of the table structure I thought that I should use a many-to-many mapping to avoid mapping an unnecessary weak entity. The root of my mapping difficulties is the different keys use to identify one of the many part (ShipmentId in the weak entity, ShipmentId + LineNo in the entity), btw I still don't know how to solve this. Anyway thinking of the problem at hand I realized that I must use ShipmentId + LineNo = 1 as an identifier for my entity.. this solve my technical issue making it a normal many-to-many issue. Thanks for helping me sorting this out :) -- Dom On 9 Feb, 22:21, Jason Meckley <[email protected]> wrote: > Udi just posted about this > topic.http://www.udidahan.com/2009/01/24/ddd-many-to-many-object-relational... > > 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 -~----------~----~----~----~------~----~------~--~---
