Sorry Fabio, but I probably still don't understand you. You say, that I can have ABclass with additional properties and I do not have to remove ICollection<A> from B? How? If it is possible it solves my problem, but I still don't know how to map model.
I don't see other solution than replace ICollection<A> in B with ICollection<ABclass>. Bartosz On 29 Lis, 12:29, Fabio Maulo <[email protected]> wrote: > emh... I think that you are mixing the persistence with what you are > exposing in your entity. > Even if, having properties, the relation have to be an ABclass with > two many-to-one nobody said that, in your A and B, you have to remove > the collection of Bs and As... > About the "change of logic": the fact that now the relation ifself has > properties, is a "change of logic" > -- > Fabio Maulo > > El 29/11/2010, a las 05:36, Bartosz Pierzchlewicz > <[email protected]> escribió: > > > > > Thanks for your answer. > > > First your advice is equivalent to replacing many-to-many relation > > with one-to- > > many, one-to-one, many-to-one which we would like to avoid. > > Because this not only changes mapping, but also require change of > > logic. (B class has collection of A, but after change it will have > > collection of 'ab' classes, which has different meaning). > > I also tried to write 'ab' class as artifact (example above), but I > > think there is no way to access them without rewriting mapping from > > many-to-many. > > > Second advise, sounds reasonable, but I have no idea how to write > > mappings to make it works. > > > Could you please to give me example? > > > Bartosz Pierzchlewicz > > > On 28 Lis, 17:45, Fabio Maulo <[email protected]> wrote: > >> If the relation has additional properties you need an "artifact" to > >> represent the relation with relation-properties; the best candidate > >> as "artifact" is a class. > > >> The other option is the usage of a Dictionary where the key is the actual > >> many-to-many and the value is a component (a class containing only the > >> properties of the relation without the relation itself). > > >> On Thu, Nov 25, 2010 at 4:24 AM, Bartosz Pierzchlewicz < > > >> [email protected]> wrote: > >>> Thanks, > >>> but I'm not sure what you mean. > >>> Could you give me a example? > > >>> On 25 Lis, 07:04, Erendrake <[email protected]> wrote: > >>>> 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]<nhusers%[email protected] > >>> > > >>> . > >>> For more options, visit this group at > >>>http://groups.google.com/group/nhusers?hl=en. > > >> -- > >> Fabio Maulo > > > -- > > 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 > > athttp://groups.google.com/group/nhusers?hl=en. -- 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.
