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?
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)
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; }Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Use the
InsertAndGetIdAsyncmethod or manually call theSaveChangesmethod of the current unit of work.Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)