Hi,
Good Morning, While updating a table the creator userid is missing and updated creator userid as null and we have tried to add using full audited entity class but also same result creator userid is updated as null. Can you please provide us solution while updating table.
This is the method we have written for updating a table
public async Task UpdateCountry(CountryInputDto input) { var country = input.MapTo<Country>(); await _countryRepository.UpdateAsync(country); }
Input Class
[AutoMapTo(typeof(Country))] public class CountryInputDto { public int Id { get; set; } public virtual string CountryName { get; set; } public virtual string CountryCode { get; set; } }
Thanks
5 Answer(s)
-
0
Hi,
Can you share Country entity as well ?
-
0
Hi, Good Evening,
[Table("Country")] public class Country : FullAuditedEntity { [Required] public virtual string CountryName { get; set; }
[Required] public virtual string CountryCode { get; set; } }
-
0
Hi,
I think you should first get country from _countryRepository, then map your input to it.
var country = await _countryRepository.GetAsync(input.Id); ObjectMapper.Map(input, country); await _countryRepository.UpdateAsync(country);
Otherwise, the fields not in CountryInputDto class will be null (or their default values) and you will also update fields not in your DTO.
Thanks.
-
0
Hi, Good Morning,
Thanks for your help, it worked.
-
0
Great :)