Search code examples
c#domain-driven-design

Domain Entities. I Do Not Understand What Is Persisted By The Infrastructure Layer


I am trying to understand Domain Driven Design. My Domain has an entity.

    public class Person
    {
       public string Name { get; set; }
       public DateTime DOB { get; set; }
       public void DoSomethingInterestingToThisPerson() { }
       //etc
    }

In the application project I have a PersonDTO used for the UI project.

        public class PersonDTO
        {
            public string Name { get; set; }

            public int Age { get; set; }
        }

The UI & the data project reference the Application. The application references the Domain project. What gets persisted in the database? Is it the PersonDTO? How do I query the db for people if the db does not "know" about the Person object?


Solution

  • Your domain should exactly match the table, you can use AutoMapper to map DTO and Entity for to and from DB operations, can you not simply do this with EntityFramework and AutoMapper?