Thanks for the help Hudson. PolicyNumber/PolicyDate is a valid domain accepted composite identifier. It's true that I can't change any of this and they are actually generated by the system. We're building support systems, so we'll never actually do inserts here.
I can see your point about relying on AutoMapping. It was worth a shot, but I've already got some failing PersistenceSpecification<T> tests. cc On Jan 19, 2:37 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote: > I'm guessing that PolicyNumber/PolicyDate in Policy are mapped as a > composite key? > > Is there any reason for this other than that's what the database has mapped > it as? Is PolicyNumber a valid entity Identifier as far as the domain model > is concerned? > > If so, then you'd just map PolicyNumber with an > Id(x=> x.PolicyNumber).GeneratedBy.Assigned(); //Just a guess on the > assigned thing since I think your app might generate them > > And map your collection like so: > HasMany<CreditCard>(x => x.CreditCards).AsBag() > .KeyColumn(PolNbr ); > > Viola. Done. No need for a where at all there. > > Now, given that I caught a mapping. prefix, I'm assuming you're using an > automapper. I'd advise against it in your case. It's very rare to expect > automapper to automagically map for a legacy database environment. Swap to > Fluent Mappings. > > > > On Tue, Jan 19, 2010 at 1:06 PM, Corey Coogan <coreycoo...@yahoo.com> wrote: > > I have 2 entities that are described below. I want to map many credit > > cards to one policy. There is no proper FK between them in our Oracle > > DB (I can't change the DB at all). They do match up on the > > PolicyNumber->PolNbr properties though. > > > I can't figure out how to map this relationship. Here's what I have > > so far, but I'm not sure how to specify the Key in the containing > > entity that doesn't match. > > > mapping.HasMany<CreditCard>(x => x.CreditCards) > > .KeyColumn(PolNbr ) > > //where to map CreditCard.PolNbr to Policy.PolicyNumber > > > Policy > > { > > PolicyNumber : string (PK) > > PolicyDate : date (PK) > > CreditCards : IList<CreditCard> > > } > > > CreditCard > > { > > PolNbr : String (PK) > > CcType : String (PK) > > ExpDt : String (PK) > > //3 more columns that are the PK > > } > > > -- > > You received this message because you are subscribed to the Google Groups > > "Fluent NHibernate" group. > > To post to this group, send email to fluent-nhibern...@googlegroups.com. > > To unsubscribe from this group, send email to > > fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/fluent-nhibernate?hl=en. > > -- > - Hudsonhttp://www.bestguesstheory.comhttp://twitter.com/HudsonAkridge
-- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibern...@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.