I am refactoring a project to bring it closer to DDD. The project is written in VB.Net and use WinForms to UI. I have been learning about DDD and I still don't have some things very clear.
I use the repository pattern and SqlKata to create and execute SQL Sentences. I read about why transactions should be handle in Application Services, but I think about some cases which to handle transaction in repositories could be a good idea. An example:
A domain model Order with a list property Lines. A service called FindOrderService. The service use the OrderRepository and its function .FindById(...). This repository return Order with its Lines. In Database Order and OrderLines are two different tables.
I. Shouldn't the repository function handle a transaction by having to use two tables to make sure the domain object is created in a consistent state? With a function .Add(...) Wouldn't the same thing happen?
II. Application services may or may not be used in a transactional manner. But they don't know how many tables are used to persist an Aggregate. Wouldn't ensuring something like this be a matter of Infrastructure even though it can also be handled from the application services?
III. From what I've read. It seems that exist two terms: "Bussines transaction" and "Technical transaction" (in this post). Are this exaples technical transactions?
Thanks in advance!
Edit:
My question, more specifically, is: if the Application Services can choose whether the service itself can initiate the Transaction from the database or not, how can it be ensured from the Repositories (if they use more than one table) that the Domain Model that must be returned or persisted is consistent?
I think in this post has been spoken about this question more in detail. This response is close to the one I am looking for, but is not clear if can be used the database transaction in the repository or how to handle this properly.