At the beginning, you need to prepare your environment and set up a test Northwind database https://northwinddatabase.codeplex.com.
Let's use a console application to demonstrate the example. Target framework for all projects should be 4.5.1. CreateNewConsoleApp.PNG AddDomainModel.PNG addNugetDomainModel.PNG AddInfrastructure.PNG AddNugetInfrastructure.PNG AddModel.PNG ModelEntities.PNG
    public partial class NorthwindEntities : IUnitOfWork
    {
        public void Commit()
        {
            SaveChanges();
        }
    }
public interface IOrderRepository : IRepository<Order>    {    }
    public class OrderRepository : RepositoryBase<Order>, IOrderRepository
    {
        public OrderRepository(IUnitOfWork unitOfWork) : base(unitOfWork, x => x.OrderID)
        {
        }
    }
Note, that you need specify primary key properties of entity when invoke base constructor.

That’s all. Your data access layer is completed.

In next example you can see examples how to use the repository.
    class Program
    {
        static void Main(string[] args)
        {
            using (var context = new NorthwindEntities())
            {
                 context.Configuration.LazyLoadingEnabled = false;                
                 IOrderRepository orderRepository = new OrderRepository(context);
 
                //find single result by key
                var order = orderRepository.Find(10248);
 
                //find single result projection by key
                var orderProjection = orderRepository.Find(10248, projection: x => new
                {
                    OrderId = x.OrderID,
                    CustomerName = x.Customer.ContactName
                });
 
                //find single result by key with eager loaded Customer association
                order = orderRepository.Find(10248, includePaths: x => x.Customer);
 
                //find single result projection by key with eager loaded Customer association
                var orderProjection2 = orderRepository.Find(10248, projection: x => new
                {
                    OrderId = x.OrderID,
                    Order = x,
                    CustomerName = x.Customer.ContactName
                }, includePaths: x => x.Customer);
 
                //find results by predicate
                var orders = orderRepository.FindBy(x => x.ShipCountry == "Russia");
 
                //find result projections by predicate
                var orderProjections = orderRepository.FindBy(x => x.ShipCountry == "Russia", projection: x => new
                {
                    OrderId = x.OrderID,
                    CustomerName = x.Customer.ContactName
                });
 
                //find result projections by predicate
                var orderProjections2 = orderRepository.FindBy(x => x.ShipCountry == "Russia", projection: x => new
                {
                    OrderId = x.OrderID,
                    CustomerName = x.Customer.ContactName
                }, includePaths: x => x.Customer);
            }
        }
    }
Description of all repository’s methods see in documentation.

Of course you can use a dependency injection container and inject your IOrderRepository contract to your services, controllers and etc.

You can download example by https://dcpddd.codeplex.com/downloads/get/1437395.