I need to write an .NET C# ApiController in Azure App Service to insert (update/delete) into multiple related tables. For example insert a record in Table A, get the new inserted record id from Table A and insert multiple records in Table B that are referenced to Table A with this RecordID.
How can I manage that?
Thanks, Uwe
You will be creating a web api and hosting it in azure app service( api app). Within the code for that given method you will the implementation within which you will make the database calls. Insert in table A and get the record ID from there and doing other CRUD operations. Firstly if you are doing it via stored procedure or entity framework there are options to get the last inserted record id for eg
Get Record ID in Entity Framework after insert
Since all the db operations have to happen together or must be rolled back you should be doing it within transactions. From Entity framework 6 onwards you have this capability
https://msdn.microsoft.com/en-us/data/dn456843.aspx
You can also do the same in ado.net or having transactions within stored procedure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.