samedi 30 janvier 2021

How to Fill objects with protected constrauctor and private prperty settes?

I have a Domain object Like this :

public class Document {
   public string Index {get; private set;}
   public string Title {get; private set;}
   public string Content {get; private set;}

   public Document (string index , string title, string content){
       ///some domain rule here
       Index = index;
       Title = title; 
       Content = content; 
   }
 
   protected Document(){}
}

Now I want to construct objects of type Document and fill their properties when I am fetching data from storage without any ORM like dapper.

I want to know how do the Dapper or JsonConvert fill objects using protected constructors and private property setters?

Aucun commentaire:

Enregistrer un commentaire