瑞雪年

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: 订阅 订阅 :: 管理 ::

功能描述:

  1. 支持Orchard中方便使用自定义数据库连接。

  2. 连接信息可配置。

 

用法:

  1. 构造函数中添加IRepositoryFactory引用

        private readonly IRepositoryFactory _repositoryFactory;

        public HomeController(IRepositoryFactory repositoryFactory)
        {
            _repositoryFactory = repositoryFactory;
        }

  2. 使用GetRepository<T>(string name),获取指定数据库连接的IRepository<T>

            IRepository<ConnectionsRecord> connectionRecordRepository = _repositoryFactory.GetRepository<ConnectionsRecord>("SqlServer DEV");
            var count = connectionRecordRepository.Table.Count();

 

下载地址:https://gallery.orchardproject.net/List/Modules/Orchard.Module.RaisingStudio.SessionFactory

GitHub地址:https://github.com/zhongzf/Orchard.Platform-Modules

posted on 2014-01-12 19:28  瑞雪年  阅读(495)  评论(1编辑  收藏  举报