Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Transactions in this framework #47

Closed
ahmedjalalmalik opened this issue Jul 28, 2018 · 1 comment
Closed

How to use Transactions in this framework #47

ahmedjalalmalik opened this issue Jul 28, 2018 · 1 comment

Comments

@ahmedjalalmalik
Copy link

ahmedjalalmalik commented Jul 28, 2018

I am trying to use Transactions in this but there is no such example and implementation. whereas in URF.Net there is an implementation of that ass shown below


using System;
using System.Data;
using Repository.Pattern.Repositories;
using TrackableEntities;

namespace Repository.Pattern.UnitOfWork
{
    public interface IUnitOfWork
    {
        int SaveChanges();
        int ExecuteSqlCommand(string sql, params object[] parameters);
        IRepository<TEntity> Repository<TEntity>() where TEntity : class, ITrackable;
        int? CommandTimeout { get; set; }
        void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified);
        bool Commit();
        void Rollback();
    }
}
@tonysneed
Copy link
Contributor

@ahmedjalalmalik EF Core gives you a transaction for free when you call SaveChangesAsync, so there is no need to explicitly begin a transaction, unless you wish to alter the default transaction settings (such as timeout or isolation level).

In case you do need to change transaction characteristics, then the best practice is to use System.Transactions, support for which was added in EF Core 2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants