示例#1
0
 public EFRepository(STERLINGASSETContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     Context = context;
     dbSet   = Context.Set <T>();
 }
示例#2
0
 public CustomerRepository(STERLINGASSETContext context) : base(context)
 {
 }
示例#3
0
        /// <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);
        }