Open Closed

Creating One-To-Many Relationships #4014


User avatar
0
bponczek created

Hey, I have a question about creating relationships between objects, basically I followed the steps Application Development Tutorial (BookStore) and wanted to ask if after creating the relation between Book and Author is it possible to show a list of books on the Author page? (So by picking an author on the Book modal, the book would automatically be added to the book list on the author's modal). If it's possible could you please point me in the right direction because I wasn't able to find anything in your documentation.

  • ABP Framework version: v6.0.0
  • UI type:Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

3 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    ... is it possible to show a list of books on the Author page? (So by picking an author on the Book modal, the book would automatically be added to the book list on the author's modal).

    I couldn't understand it clearly. Do you want list of books inside the author create/update modal or list of authors inside the book create/update modal?

    If you want to list the books in author create/update modal, it will be very ineffective since there should be way too many book records than the author records. When creating a new author, you will be loading all the books just to assign to an author.

    If you want to do so, use the BookAppService to get all the books and you can use select2 library to add single or multiple items.

    If you want to show the author list inside the book create/update modal, it is how the tutorial approaches.

  • User Avatar
    0
    bponczek created

    I want to show a single author picker inside the book create/update modal AND a collection of Books on the author create/update modal.

    Basically i want the association to be visible in both modal’s.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    As I have mentioned above, you can inject the BookAppService and use the leptonx select2 to list them in the modal.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19