Skip to content

Instantly share code, notes, and snippets.

@ashutoshraina
Created November 30, 2012 12:12
Show Gist options
  • Save ashutoshraina/4175430 to your computer and use it in GitHub Desktop.
Save ashutoshraina/4175430 to your computer and use it in GitHub Desktop.
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