Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

How to implement a specific repository pattern

$
0
0

i got only interface code for repository pattern. see the interface and tell me how could i implement it by a class because i could not visualize how to write method body of all interface function when a class will implement this interface. so need help for sample code.

public interface IRepository<TEntity> : IDisposable
            where TEntity : class
    {
        bool IsDisposed { get; }

        TEntity Find(params object[] keyValues);

        TEntity Find(Expression<Func<TEntity, bool>> filter,
                     Expression<Func<TEntity, object>>[] include = null);

        Task<TEntity> FindAsync(Expression<Func<TEntity, bool>> filter,
                                Expression<Func<TEntity, object>>[] include = null);

        IQueryable<TEntity> Query(Expression<Func<TEntity, object>>[] include = null);

        TEntity Create();

        TEntity Create(TEntity value);

        bool Update(TEntity value);

        void Delete(TEntity value);

        void Delete(IEnumerable<TEntity>entities);

        void Reset(TEntity value);

        Task ResetAsync(TEntity value);

    }


public interface IUnitOfWork : IDisposable
    {

        IRepository<TEntity> GetRepository<TEntity>()
            where TEntity : class;

        int SaveChanges();

        Task<int> SaveChangesAsync();

        IEnumerable<TEntity> Invoke<TEntity>(string procedure, IDictionary<string, object> parameters);

        IEnumerable<TEntity> Invoke<TEntity>(string procedure, object parameters);

        int Invoke(string procedure, IDictionary<string, object> parameters);

        int Invoke(string procedure, object parameters);
    }

i would like to use EF6 with repository pattern and UoW.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>