I am adding a new data member in a class which is part of shared nuget package. On Server application, I need to support both nuget packages, previous nuget package member does not have newly added member. How do I map this member so my code does not break. Please review following code.
Nuget Package 1.0
Class Employee
{
public int Id {get; set;}
public string Address { get; set;}
}
Nuget Package 1.1
Class Employee
{
public int Id {get; set;}
public string Address { get; set;}
public string Department { get; set;}
}
From the client, if Department member is not passed I want to set server Department to Null else set the value passed by client.
Although I'm not sure I fully understand the issue I believe what your looking for may be auto-property initializers:
class Employee
{
public int Id {get; set;}
public string Address { get; set;}
public string Department { get; set;} = null;
}
Look here for more information: https://msdn.microsoft.com/en-us/magazine/dn802602.aspx