I am using GraphQL.NET with asp.net core 3.1 to develop graphql based apis. I have the following code:
ContactDTO.cs
public class ContactDTO
{
public int ContactId { get; set; }
public int? ImageId { get; set; }
public string ImagePath { get; set; }
public string OfficePhone { get; set; }
public string OfficeFaxNumber { get; set; }
public string MobilePhoneNumber { get; set; }
public string Email { get; set; }
public string Website { get; set; }
public string FaceBookUrl { get; set; }
public string TwitterUrl { get; set; }
public string LinkedInUrl { get; set; }
public string GooglePlusUrl { get; set; }
public string WeChatUrl { get; set; }
public string WeboUrl { get; set; }
public string XINGUrl { get; set; }
public string VKUrl { get; set; }
public int? CountryId { get; set; }
public string CreatedDate { get; set; }
public string UpdatedDate { get; set; }
public string EmpGUID { get; set; }
public int? LanguageId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string NativeName { get; set; }
public string Title { get; set; }
public string Role { get; set; }
public string EmployeeLevel { get; set; }
public string Introduction { get; set; }
public string Organization { get; set; }
public string OrganizationUnitName { get; set; }
public int AddressId { get; set; }
public AddressDTO address { get; set; }
}
}
AddressDTO.cs
public class AddressDTO
{
public int AddressId { get; set; }
public string Street { get; set; }
public string Country { get; set; }
public string City { get; set; }
}
ContactType.cs
public class ContactType : ObjectGraphType<ContactDTO>, IGraphQLType
{
public ContactType()
{
Name = "Contact";
Field(co => co.ContactId, nullable: true);
Field(co => co.OfficePhone, nullable: true);
Field(co => co.OfficeFaxNumber, nullable: true);
Field(co => co.MobilePhoneNumber, nullable: true);
Field(co => co.Email, nullable: true);
Field(co => co.Website, nullable: true);
Field(co => co.FaceBookUrl, nullable: true);
Field(co => co.TwitterUrl, nullable: true);
Field(co => co.LinkedInUrl, nullable: true);
Field(co => co.GooglePlusUrl, nullable: true);
Field(co => co.WeChatUrl, nullable: true);
Field(co => co.WeboUrl, nullable: true);
Field(co => co.XINGUrl, nullable: true);
Field(co => co.VKUrl, nullable: true);
Field(co => co.FirstName, nullable: true);
Field(co => co.LastName, nullable: true);
Field(co => co.NativeName, nullable: true);
Field(co => co.Title, nullable: true);
Field(co => co.Role, nullable: true);
Field(co => co.EmployeeLevel, nullable: true);
Field(co => co.Introduction, nullable: true);
Field(co => co.Organization, nullable: true);
Field(co => co.OrganizationUnitName, nullable: true);
Field(co => co.ImagePath, nullable: true);
Field<AddressType>(
"address",
resolve: context =>
{
return context.Source.address;
}
);
}
}
In the above the ContactType.cs is very extensive class with many properties that are inherited from the ContactDTO.cs.
I am looking for a way to map all the properties of ContactDTO.cs to the ContactType.cs.
Can anyone help me to do this mapping in better way