One thing i tried before was to add another relationship. You end up with the ManyToMany as well as two ManyToOne with the AB table in the middle. its not perfect but it worked for me in my app. hope it helps
On Nov 24, 1:06 am, Bartosz Pierzchlewicz <[email protected]> wrote: > Hi, > My problem is easy to explain, but difficult to solve. > We using NN 2.1. (rev 4896) > I have two classes and many-to-many relation between them (sorry for > using AR notation) > > [ActiveRecord] > public class A > { > [Property] > public string NameA { get; set; } > } > > [ActiveRecord] > public class B > { > [Property] > public string NameB { get; set; } > > [HasAndBelongsToMany(typeof(A),Table = "ab", ColumnKey = "b", > ColumnRef = "a")] > public ICollection<A> ACollection { get; set; } > } > > Now, I have to add some fields do ab table like modificationUser and > modificationDate. > So I wrote mapping class like that (I know, that we can use composite > key): > > [ActiveRecord] > public class ab > { > [PrimaryKey] > public int Id { get; set; } > > [BelongsTo] > public A a { get; set; } > > [BelongsTo] > public B b { get; set; } > > [Property] > public string ModificationUser { get; set; } > > [Property] > public DateTime ModificationDate { get; set; } > } > > Now comes the question: is there any way to access ModificationUser > and ModificationDate fields? > > I tried using EventListener, but no success. > Maybe NH interceptors, or writing own custom CollectionPersister? > > It is not solution for us to replace many-to-many relation with one-to- > many, one-to-one, many-to-one, because ACollection is already used in > many hql queries, and changing from ICollection<A> ACollection to > ICollection<ab> ABCollection require to rewrite them all. > > Thanks for any help. -- 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.
