c# - Reusing models in Web Api -
i have c# class below
public class createstudent { public int id { get; set; } public string name { get; set; } public string address { get; set; } public int age { get; set; } }
and need class following properties
public class editstudent { public string name { get; set; } public string address { get; set; } public int age { get; set; } public datetime date_of_birth { get; set; } }
i have repeated properties except 1 field (date_of_birth) added in editstudent model. there option reuse of properties previous createstudent model
i going handle these data json objects in front end angularjs based application
you null-able property.
public class student { public int id { get; set; } public string name { get; set; } public string address { get; set; } public int age { get; set; } public datetime? date_of_birth { get; set; } }
this way have 1 student model can accommodate both use-cases.
Comments
Post a Comment