Base solution for your next web application
Open Closed

Many to many DTO example needed #9684


User avatar
0
Tkorytnyuk created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? 9.11
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net core

Hi,

How can I create many-to-many relationship DTO? In other words, I can't find any good example.
I have followed EF Core examples and I have already created two Entity tables and one intermediary table.

The question is: how do I properly create DTO objects for Selecting, Editing, Inserting of these entities, and their relationships.

Can you please point to an example?

Thank you!

Edit: maybe you can point me out to an example in aspnetboilerplate or asp.net zero where many-to-many is implemented/used?


8 Answer(s)
  • User Avatar
    0
    zony created
    Support Team

    Hi Tkorytnyuk, In the ABP framework source code, roles and users are a typical example, you can read the relevant source code. Each project corresponds to multiple people, the following is an example.

    public class PersonDto
    {
        public string Name { get; set; }
    
        public int Age { get; set; }
    }
    
    public class ProjectCreateOrUpdateDto
    {
        public string Name { get; set; }
    
        public string Description { get; set; }
        
        public List<long> PersonIds { get; set; }
    }
    
    // Details Dto
    public class ProjectDto
    {
        public string Name { get; set; }
    
        public string Description { get; set; }
    
        public List<PersonDto> Persons { get; set;}
    }
    

    if you need,I will upload the demo file as an attachment tomorrow.

  • User Avatar
    0
    Tkorytnyuk created

    thanks, zony. I'll be waiting.

  • User Avatar
    0
    Tkorytnyuk created

    Any updates @zony?

  • User Avatar
    0
    zony created
    Support Team

    Hi Tkorytnyuk, Due to the recent busy schedule, I will upload the corresponding attachments on October 1st.

  • User Avatar
    0
    zony created
    Support Team

    Hi Tkorytnyuk, The file demo-code.zip contains sample code.

  • User Avatar
    0
    Tkorytnyuk created

    Hi thank you, but where is the zip file?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Tkorytnyuk

    We will upload the zip file in a short time. You can also try new Power Tools with latest version of AspNet Zero and crete a new mster-detial sample to see such a relationship.

  • User Avatar
    0
    zony created
    Support Team

    Hi Tkorytnyuk, Sorry, I missed the zip file, I have re-uploaded it. https://1drv.ms/u/s!AhvCnUPNy3pUgY5VPlbVbanmF7aqQw?e=zSfCtf