I've been experimenting with C# and DevExpress and came across a situation for which I cannot find a simple solution.
I've got three objects:
- Book
- Author
- Series
- A
Book
has a collection ofAuthor
s (Many-to-Many) - An
Author
has a Collection ofBook
s (Many-to-Many) - A
Series
has two collections;Books
andAuthors
- Both
Book
andAuthor
have aSeries
collection
My problem is that whenever I add a Book
to a Series
, the Author
(s) of that Book
should also be added to the Series
.
[Association("SeriesBooks")]
public XPCollection<Book> Books => GetCollection<Book>(nameof(Books));
[Association("SeriesAuthors")]
public XPCollection<Author> Authors
{
get { return GetCollection<Author>("Authors"); }
}
I've considered the following:
- Use the
OnSaving
event - Adding a setter to my associations
- Using the
AfterConstruction
But since I'm a beginner, I haven't been able to actually get anything out of this.
I'd be glad with all the help you can offer.