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
Bookhas a collection ofAuthors (Many-to-Many) - An
Authorhas a Collection ofBooks (Many-to-Many) - A
Serieshas two collections;BooksandAuthors - Both
BookandAuthorhave aSeriescollection
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
OnSavingevent - 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.