0
antonis created
Hi,
I have the following code
Client newClient = await clientRepository.InsertAsync(clientInput);
return ObjectMapper.Map<ClientDto>(newClient);
I am trying to return the new id back to the client. But apparently the Id of the newClient is a huge number -9223372036854775000 which means that the row was inserted but for some reason the Id was not set in the Client object.
How can I overcome this issue?
2 Answer(s)
-
1
Here is an example of how I do it in my app.
public async Task<long> CreateAddress(CreateAddressInput input) { var address = ObjectMapper.Map<Address>(input); if (AbpSession.TenantId != null) { address.TenantId = (int)AbpSession.TenantId; } //Create address var newId = await _addressRepository.InsertAndGetIdAsync(address); return newId; }
-
0
Use the
InsertAndGetIdAsync
method or manually call theSaveChanges
method of the current unit of work.