Example #1
0
        public static void ConfigureRepositoryWrapper(this IServiceCollection services, IConfiguration config)
        {
            var connectionString = config["sqlconnection:connectionString"];
            var optionsBuilder   = new DbContextOptionsBuilder <PostCommentDBContext>();

            optionsBuilder.UseSqlServer(connectionString);
            var context = new PostCommentDBContext(optionsBuilder.Options);

            services.AddSingleton <IPostItemRepository>(new PostItemRepository(context));
            services.AddSingleton <ICommentRepository>(new CommentRepository(context));
            services.AddSingleton <IUserRepository>(new UserRepository(context));
            context.EnsureSeedDataForContext();
        }
 public CommentRepository(PostCommentDBContext postCommentDBContext)
 {
     this.postCommentDBContext = postCommentDBContext;
 }