I have a relational database that I prepared with the DbFirst approach. While posting entity class for post model it goes in property of other class type inside entity class. Below are the properties of my entity class.
public class CurrencyAccount : BaseEntity
{
[ForeignKey("CompanyId")]
public int CompanyId { get; set; } // Company Class
public string Code { get; set; } // Use for transfer data to other software
public string Name { get; set; }
public string Adress { get; set; }
public string? TaxOffice { get; set; } // Nullable
[MaxLength(10)]
public string? TaxIdNumber { get; set; } // Nullable char(10)
[MaxLength(11)]
public string? IdentityNumber { get; set; } // Nullable char(11)
public string? Email { get; set; } // Nullable
public string? Authorizedperson { get; set; } // Nullable
// Navigation Property
public Company? Company { get; private set; }
public List<BaBsReconciliation>? BaBsReconciliations { get; private set; }
public List<AccountReconciliation>? AccountReconciliations { get; private set; }
Below are the codes of the Add method in my API control
[HttpPost("add")]
public IActionResult Add(CurrencyAccount currencyAccount)
{
var result = _currencyAccountService.Add(currencyAccount);
if (result.IsSuccess)
{
return Ok(result);
}
return BadRequest(result.Message);
}
Below is the screenshot of Swagger
Briefly, as you can see in the screenshot, I don't want the Company class inside the CurrencyAccount class in the post operation. Thank you so much
As far as I can understand, you should use DTO's . You can specify which you want to see.