Saturday, March 30, 2019

One class per file for related EF classes?

I've been really taking advantage of the "Paste JSON as class" feature in visual studio for DTOs and entities. However, with a nested object, you often end up with something like this:

public class Rootobject

{

public string date { get; set; }

public bool active { get; set; }

public Start start { get; set; }

public End end { get; set; }

public Slot[] slots { get; set; }

}

public class Start

{

public string hour { get; set; }

public string minute { get; set; }

}

public class End

{

public string hour { get; set; }

public string minute { get; set; }

}

public class Slot

{

public string time { get; set; }

public string hour { get; set; }

public string minute { get; set; }

public bool blocked { get; set; }

}

Would you guys separate these out into their own files? Or just leave it in a RootObject.cs. I realize its just a style and practice thing, and I might just be being lazy, but I also don't want to litter my entities folder with stuff like the End object. I also do realize the Start and End objects are the same, but they need to be differentiated during reflection - just so I don't get roasted for that.

One class per file for related EF classes? Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team