Create a gist now

Instantly share code, notes, and snippets.

Embed
EF Code First Repository Pattern
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