Created
November 30, 2012 12:12
-
-
Save ashutoshraina/4175430 to your computer and use it in GitHub Desktop.
EF Code First Repository Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IRepository<T> where T: class | |
{ | |
void Add( T Entity); | |
void Delete( T Entity); | |
void Update ( T Entity); | |
IQueryable<T> GetAll<T>(); | |
//some more methods | |
} | |
public interface IDatabaseFactory : IDisposable | |
{ | |
MyContext GetContext () | |
{} | |
} | |
public interface IUnitOfWork | |
{} | |
public class UnitOfWork : IUnitOfWork | |
{ | |
void commit(); | |
} | |
public abstract class RepositoryBase<T> where T:class | |
{} | |
public class DatabaseFactory | |
{} | |
public class Disposable | |
{} | |
public class Mycontext : Dbcontext | |
{} | |
//Concrete Repository | |
public interface ICustomerRepository : IRepository<Customer> | |
{ | |
//Some methods to do customer specific stuff | |
} | |
public class CustomerRepository : RepositoryBase<Customer> , ICustomerRepository | |
{ | |
//Implementation of some stuff | |
} | |
//More repositories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment