I have a class that is built up from a REST response (ClientInformationResponse
). As a test, I copied the class (PolicyDetailInformation
) almost exactly and want to see if the ServiceStack automapping works correctly for a large object.
The original object is populated with info as follows:
Then I try:
new PolicyDetailInformation().PopulateWith(client)
Which does not map correctly:
I have also tried:
client.ConvertTo<PolicyDetailInformation>()
I’m not sure why things are not being mapped correctly?
The original ClientInformationResponse
classes:
public class ClientInformationResponse
{
[JsonProperty("MainPersonalInfo")]
public MainPersonalInfo MainPersonalInfo { get; set; }
[JsonProperty("MainMyProducts")]
public MainMyProduct[] MainMyProducts { get; set; }
// [JsonProperty("MainClaimDetail")]
// public MainClaimDetail[] MainClaimDetail { get; set; }
[JsonProperty("MainMyProductsDetail")]
public MainMyProductsDetail[] MainMyProductsDetail { get; set; }
[JsonProperty("MainVehicleDetails")]
public MainVehicleDetail[] MainVehicleDetails { get; set; }
[JsonProperty("MainSignUpInformation")]
public MainSignUpInformation MainSignUpInformation { get; set; }
[JsonProperty("MainVehicles")]
public MainVehicle[] MainVehicles { get; set; }
public List<MainBeneficiariesInfo> MainBeneficiariesInfo { get; set; }
public List<MainDependantsInfo> MainDependantsInfo { get; set; }
}
public class MainBeneficiariesInfo
{
public bool IsDependant { get; set; }
public bool IsBeneficiary { get; set; }
public string Relation { get; set; }
public string Name { get; set; }
public string ID { get; set; }
public string Cell { get; set; }
public string Business { get; set; }
public string Home { get; set; }
public string Email { get; set; }
public string PhysicalAddress { get; set; }
}
public class MainDependantsInfo
{
public bool IsDependant { get; set; }
public bool IsBeneficiary { get; set; }
public string Relation { get; set; }
public string Name { get; set; }
public string ID { get; set; }
public string Cell { get; set; }
public string Business { get; set; }
public string Home { get; set; }
public string Email { get; set; }
public string PhysicalAddress { get; set; }
}
public class MainPersonalInfo
{
[JsonProperty("Home")]
public string Home { get; set; }
[JsonProperty("Cell")]
public string Cell { get; set; }
[JsonProperty("Business")]
public string Business { get; set; }
[JsonProperty("Email")]
public string Email { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("ID")]
public string ID { get; set; }
[JsonProperty("PhysicalAddress")]
public string PhysicalAddress { get; set; }
}
public class MainMyProduct
{
[JsonProperty("PlatformReference")]
public string PlatformReference { get; set; }
[JsonProperty("ProductCode")]
public string ProductCode { get; set; }
[JsonProperty("ClientIDNumber")]
public string ClientIDNumber { get; set; }
[JsonProperty("PolicyNumber")]
public string PolicyNumber { get; set; }
[JsonProperty("ProductName")]
public string ProductName { get; set; }
}
public class MainClaimDetail
{
[JsonProperty("ClaimNumber")]
public string ClaimNumber { get; set; }
[JsonProperty("AuthDate")]
public string AuthDate { get; set; }
[JsonProperty("AuthAmount")]
public string AuthAmount { get; set; }
[JsonProperty("ClaimDate")]
public string ClaimDate { get; set; }
[JsonProperty("PolicyNumber")]
public string PolicyNumber { get; set; }
[JsonProperty("ClientIDNumber")]
public string ClientIDNumber { get; set; }
[JsonProperty("ProductCode")]
public string ProductCode { get; set; }
[JsonProperty("Status")]
public string Status { get; set; }
}
public class MainMyProductsDetail
{
[JsonProperty("PolicyNumber")]
public string PolicyNumber { get; set; }
[JsonProperty("ClientIDNumber")]
public string ClientIDNumber { get; set; }
[JsonProperty("ClaimsContact")]
public string ClaimsContact { get; set; }
[JsonProperty("PlatformReference")]
public string PlatformReference { get; set; }
[JsonProperty("ProductName")]
public string ProductName { get; set; }
[JsonProperty("ProductCode")]
public string ProductCode { get; set; }
[JsonProperty("Status")]
public string Status { get; set; }
}
public class MainVehicleDetail
{
[JsonProperty("Manufactures")]
public string Manufactures { get; set; }
[JsonProperty("EngineNumber")]
public string EngineNumber { get; set; }
[JsonProperty("ClientIDNumber")]
public string ClientIDNumber { get; set; }
[JsonProperty("Kilometers")]
public string Kilometers { get; set; }
[JsonProperty("RegisterNumber")]
public string RegisterNumber { get; set; }
[JsonProperty("Model")]
public string Model { get; set; }
[JsonProperty("VehicleNumber")]
public string VehicleNumber { get; set; }
}
public class MainSignUpInformation
{
[JsonProperty("IDNumber")]
public string IDNumber { get; set; }
[JsonProperty("CellNumber")]
public string CellNumber { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Surname")]
public string Surname { get; set; }
}
public class MainVehicle
{
[JsonProperty("Make")]
public string Make { get; set; }
[JsonProperty("RegisterNumber")]
public string RegisterNumber { get; set; }
[JsonProperty("ClientIDNumber")]
public string ClientIDNumber { get; set; }
[JsonProperty("Model")]
public string Model { get; set; }
[JsonProperty("VINNumber")]
public string VINNumber { get; set; }
}
The class I want to map to PolicyDetailInformation
:
public class PolicyDetailInformation
{
public MainPersonalInfo MainPersonalInfo { get; set; }
public MainMyProduct[] MainMyProducts { get; set; }
// [JsonProperty("MainClaimDetail")]
// public MainClaimDetail[] MainClaimDetail { get; set; }
public MainMyProductsDetail[] MainMyProductsDetail { get; set; }
public MainVehicleDetail[] MainVehicleDetails { get; set; }
public MainSignUpInformation MainSignUpInformation { get; set; }
public MainVehicle[] MainVehicles { get; set; }
public List<MainBeneficiariesInfo> MainBeneficiariesInfo { get; set; }
public List<MainDependantsInfo> MainDependantsInfo { get; set; }
}
public class MainBeneficiariesInfo
{
public bool IsDependant { get; set; }
public bool IsBeneficiary { get; set; }
public string Relation { get; set; }
public string Name { get; set; }
public string ID { get; set; }
public string Cell { get; set; }
public string Business { get; set; }
public string Home { get; set; }
public string Email { get; set; }
public string PhysicalAddress { get; set; }
}
public class MainDependantsInfo
{
public bool IsDependant { get; set; }
public bool IsBeneficiary { get; set; }
public string Relation { get; set; }
public string Name { get; set; }
public string ID { get; set; }
public string Cell { get; set; }
public string Business { get; set; }
public string Home { get; set; }
public string Email { get; set; }
public string PhysicalAddress { get; set; }
}
public class MainPersonalInfo
{
public string Home { get; set; }
public string Cell { get; set; }
public string Business { get; set; }
public string Email { get; set; }
public string Name { get; set; }
public string ID { get; set; }
public string PhysicalAddress { get; set; }
}
public class MainMyProduct
{
public string PlatformReference { get; set; }
public string ProductCode { get; set; }
public string ClientIDNumber { get; set; }
public string PolicyNumber { get; set; }
public string ProductName { get; set; }
}
public class MainClaimDetail
{
public string ClaimNumber { get; set; }
public string AuthDate { get; set; }
public string AuthAmount { get; set; }
public string ClaimDate { get; set; }
public string PolicyNumber { get; set; }
public string ClientIDNumber { get; set; }
public string ProductCode { get; set; }
public string Status { get; set; }
}
public class MainMyProductsDetail
{
public string PolicyNumber { get; set; }
public string ClientIDNumber { get; set; }
public string ClaimsContact { get; set; }
public string PlatformReference { get; set; }
public string ProductName { get; set; }
public string ProductCode { get; set; }
public string Status { get; set; }
}
public class MainVehicleDetail
{
public string Manufactures { get; set; }
public string EngineNumber { get; set; }
public string ClientIDNumber { get; set; }
public string Kilometers { get; set; }
public string RegisterNumber { get; set; }
public string Model { get; set; }
public string VehicleNumber { get; set; }
}
public class MainSignUpInformation
{
public string IDNumber { get; set; }
public string CellNumber { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
}
public class MainVehicle
{
public string Make { get; set; }
public string RegisterNumber { get; set; }
public string ClientIDNumber { get; set; }
public string Model { get; set; }
public string VINNumber { get; set; }
}