Home > front end >  how to create DTO in C# .net
how to create DTO in C# .net

Time:10-18

OOD table

Hi I'm wondering how would you write the dto of what i underlined. would it be something like this

    public Student EnrolledStudents
    {
        get; private set;
    }

CodePudding user response:

Just Create a class that includes the field of what you want in DTO. and Then Initialize the object simply in your buisness logic class/in repository where your data is being fetched.

CodePudding user response:

A DTO is really just a stupid class, that can hold data. Therefore you can create a class with the property you posted, although based on the picture you posted, i would say that maybe it's a list?

public class MyDto {
    public List<Student> EnrolledStudents {get; private set;}
}
  • Related