A while back i created repositories and services using linq to sql and I struggled to understand it. I finally understood it but Now I'm trying to do the same thing but using Code First EF. I'm confused on how this works with code first. If I have one repository that I can just pass in a class object and have select(), ect...How does this interact or how do I connect this to the/a DbContext? If someone can point me in the right direction or give me some advice it would be appreciated. Not much on this stuff on google since it's a relatively new pattern still.
How to use / would I use DbSet? These repositories are cool but confusing.
public class IRepository<T> : IDisposable
where T : class, new()
{
IQueryable<T> Select();
IQueryable<T> SelectWith(params Expression<Func<T, object>>[] includeProperties);
T GetById(int id);
T GetByIdWith(int id, params Expression<Func<T, object>>[] includeProperties);
void InsertOnCommit(T model);
void DeleteOnCommit(T model);
}
public class DataContext : DbContext
{
}
private DataContext contextin the repositories implementIRepository<T>.