I have a sealed and public class objects consumed in many classes of the project.
public sealed class Customer {
public int Id{get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
public string MiddleName {get; set;}
public string Address {get; set;}
}
public class PageRequest
{
public int CurrentPage {get; set;}
public int PerPage {get; set;}
public string SortBy {get; set;}
}
I would need to create a new class object with all the properties combined in both the classes rather than repeating all the properties. The following can bring in the pagerequest properties into the new class, but how can I manage to get the properties of Customer class. I cannot inherit the properties of the Customer as it's a sealed class. Removing sealed from Customer may not be a good idea as it's been used by many areas of application, even then I cannot have both Customer and PageRequest as base classes. I am ok to change the existing Customer class if there is a better approach
public class NewClass : PageRequest
{
}
Is repeating the properties in the NewClass like below a better one?
public class NewClass : PageRequest
{
public int Id{get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
public string MiddleName {get; set;}
public string Address {get; set;}
}
This new class object will be used as part of new api get request query string where a user has to provide one or many of (firstname, lastname, address) and currentpage, perpage, sortby as input parameters, need a better approach to fit all the parameters with the request. I want to use this class as a get request (http://someendpoint&firstname=a&lastname=b¤tpage=1&perpage=10
)
public Task<PaginatedResult<SomeDto>> GetResult([FromQuery]NewClass request)
{
}