On Wednesday, August 24, 2016 at 8:21:20 AM UTC-4, Ivan Ruiz de Eguilaz Sosoaga wrote: > > I have problems generating a new table by using HasManyToMany only When I > have a IDictonary as a source, for instance If I try it with an IList I do > not have any problem and I see how a new table is generated and the > relations. But I need to use a IDictioonary > > The example: >
I once had a minor use case that involved a many to many joining table, but soon discovered that made better sense as a "joining" first class entity, especially when you factor in such "impedance mismatches" as properties on that relationship. Things like dates/times, flags, or other properties that might make sense to describe the relationship. In either case, the trick, of course, is to ensure that both sides of the relational entity are persisted prior to persisting the joining entity. In this way, then either side of the relationship may be treated "simply" as a bidirectional relationship and/or re-hydrated as opportunities arise. HTH public class Email: I_CLASS > { > > public virtual int Id { get; set; } > public virtual IDictionary<Person, short> Destiny_Persons { get; set; } > > } > > public class Person: I_CLASS > { > > public virtual int Id { get; set; } > > > } > > class Notification_DTO_Map : IAutoMappingOverride<Notification_DTO> > { > public void Override(AutoMapping<Notification_DTO> mapping) > { > > mapping.HasManyToMany<User_DTO>(x => > x.Destiny_Users).Table("Destiny_Persons") > .ParentKeyColumn("Email") > .ChildKeyColumn("Person") > .AsEntityMap().Element("Email_Status", part => > part.Type<short>()); > } > > } > > my target is to have that dictionary and a new table called > Destiny_Persons with the followinf attributtes: > > - Person_Id (int) PK FK > - Email_Id (int) PK FK > - Status (short) not null > > The status won´t be part of the PK > > If a use a IList like this public virtual IList<Person> Destiny_Persons { > get; set; } > and in the mapping: mapping.HasManyToMany(x => > x.Destiny_Persons ).Table("Destiny_Persons"); > this works without the Status attributte > > I have tried a lot of different ways of putting this such as changing the > order of the elements in the dictionary <short, Person>, using asMap > instead of AsEntityMap, not using partenkeycolums and child, changing the > order... and so on > > I do not have any error when I generate the database but I am not able to > generate the table Destiny_Persons when I have a IDictionary as a source > > Thanks > > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibernate+unsubscr...@googlegroups.com. To post to this group, send email to fluent-nhibernate@googlegroups.com. Visit this group at https://groups.google.com/group/fluent-nhibernate. For more options, visit https://groups.google.com/d/optout.