-
Notifications
You must be signed in to change notification settings - Fork 3
Model Transaction
Gwenael Fillon edited this page Sep 19, 2018
·
5 revisions
=> Use it in a service like that:
bool wasInTransaction = GenericTransaction.BeginTransaction();
//Make your create, update, insert or delete
GenericTransaction.EndTransaction(wasInTransaction);=>Else add mapping classes to use easily those template :
using BIA.Net.Model.DAL;
using System;
/// <summary>
/// Generic transaction constructor.
/// </summary>
public class GenericTransaction : TGenericTransaction<ZZProjectNameZZDBContainer>
{
/// <summary>
/// Method to commit the transaction
/// </summary>
/// <param name="rootModeInTransaction">Define if the root made is true or false</param>
public static void EndTransaction(bool rootModeInTransaction)
{
if (DelegateSuccesStatic == null)
{
DelegateSuccesStatic = FinalizeTransaction;
}
BaseEndTransaction(rootModeInTransaction);
}
/// <summary>
/// Method to finalize the action after the transaction to do any action
/// </summary>
/// <param name="rootModeInTransaction">Define if the root made is true or false</param>
private static void FinalizeTransaction(bool rootModeInTransaction)
{
if (!rootModeInTransaction)
{
/* do any action */
}
}
}
BIA.Net