public partial class Employee
{
public int EmployeeId { get; set; }
public string LastName { get; set; }
public string FirstName { get; set; }
public string Title { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string Region { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
}
dto class
{
public int EmployeeId { get; set; }
public string LastName { get; set; }
public string FirstName { get; set; }
public string Title { get; set; }
public string infoAdress{get; set;}
public string Address { get; set; }
public string City { get; set; }
public string Region { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
}
get method
public async Task<ActionResult<IEnumerable<EmployeeDto>>> GetEmployees()
{
return await _context.Employees
.ProjectTo<EmployeeDto>(_imapper.ConfigurationProvider).ToListAsync();
}
body api is:
{
"employeeId": 0,
"lastName": "string",
"firstName": "string",
"adressInfo": "string",
"address": "string",
"city": "string",
"region": "string",
"postalCode": "string",
"country": "string"
}
I want the method to return me only this data:
{
"employeeId": 0,
"lastName": "string",
"firstName": "string",
"adressInfo": "string",
}
In adressInfo, I concatenate the strings Address, City, Region, Postal Code and Country, the single strings, I need to declare them for reverseMap for the post method.
Someone who gives me a tip?
Sorry for my English, is not sufficient.