public EFRepository(STERLINGASSETContext context) { if (context == null) { throw new ArgumentNullException("context"); } Context = context; dbSet = Context.Set <T>(); }
public CustomerRepository(STERLINGASSETContext context) : base(context) { }
/// <summary>Make a repository of type T.</summary> /// <typeparam name="T">Type of repository to make.</typeparam> /// <param name="dbContext"> /// The <see cref="DbContext"/> with which to initialize the repository. /// </param> /// <param name="factory"> /// Factory with <see cref="DbContext"/> argument. Used to make the repository. /// If null, gets factory from <see cref="_repositoryFactories"/>. /// </param> /// <returns></returns> protected virtual T MakeRepository <T>(Func <STERLINGASSETContext, object> factory, STERLINGASSETContext dbContext) { var f = factory ?? _repositoryFactories.GetRepositoryFactory <T>(); if (f == null) { throw new NotImplementedException("No factory for repository type, " + typeof(T).FullName); } var repo = (T)f(dbContext); Repositories[typeof(T)] = repo; return(repo); }