Implement transaction and rollback for multiple Procedure from .net.core 6 c# ADO.net application

Binumon George 161 Reputation points
2023-01-13T13:02:36.2366667+00:00

HI All,

     I am giving Below my API Model structure 




  public int organizationNPI { get; set; }
        [Required]
        public string  organizationName { get; set; }
        [Required]
        public string organizationTIN { get; set; }
        [Required]
        public string website { get; set; }
        
        public IEnumerable<Location> ?location { get; set; }
        public IEnumerable<Contact>? contact { get; set; }
        public IEnumerable<Specialities> ?specialities { get; set; }
        public IEnumerable<Languages>? languages { get; set; }


As you seeing in model There is some Basic Information and some additional information in List. So i am using different Procedure for inserting  these data. Here my question is  if  fail one of the procedure i want to roll back entire transaction from entire procedure. These procedure calling from DAL file. So How implement transaction this situation from c#
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,551 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
147 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 28,036 Reputation points
    2023-01-13T19:13:32.63+00:00

    it will depend on which ado.net library you will use. .net 6 does not support the distributed transaction manager, so you should use the same connection, (or join the transaction if supported) and use begin tran / commit tran commands.

    No comments