public DbContext(IDataProviderOptions options) : base(PetaPoco.DatabaseConfiguration.Build() .UsingDefaultMapper <DomainMapper>() .UsingConnectionString(options.ConnectionString) .UsingProviderName(options.ProviderName) .UsingCommandTimeout(options.CommandTimeOut)) { KeepConnectionAlive = true; //IsolationLevel = System.Data.IsolationLevel.ReadUncommitted; //CommandExecuted += DbContext_CommandExecuted; }
/// <summary> /// Constructor. /// </summary> /// <param name="dataSerializer">The <see cref="IDataProvider{T}"/> which will be used to serialize data from file.</param> /// <param name="fileOptionsAccessor">The <see cref="IDataProviderOptions{T,TOptions}"/> which will be used to access options for the instance of the provider.</param> public FileDataProvider( IDataSerializer <T> dataSerializer, IDataProviderOptions <T, FileProviderOptions> fileOptionsAccessor) { _dataSerializer = dataSerializer; var fileOptions = fileOptionsAccessor.Value; _fileInfo = new FileInfo(fileOptions.Path); if (!_fileInfo.Exists) { throw new InvalidOperationException($"File '{_fileInfo.FullName}' does not exist"); } _fileName = fileOptions.Path; _fileExtension = _fileInfo.Extension; }
/// <summary> /// Constructor. /// </summary> /// <param name="logger">The <see cref="ILogger{EtcdDataProvider}"/> which will be used to log events by the provider.</param> /// <param name="dataSerializer">The <see cref="IDataProvider{T}"/> which will be used to serialize data from Etcd.</param> /// <param name="etcdProviderOptionsAccessor">The <see cref="IDataProviderOptions{T,TOptions}"/> which will be used to access options for the instance of the provider.</param> public EtcdDataProvider(ILogger <EtcdDataProvider <T> > logger, IDataSerializer <T> dataSerializer, IDataProviderOptions <T, EtcdProviderOptions> etcdProviderOptionsAccessor) { _logger = logger; _dataSerializer = dataSerializer; _etcdProviderOptions = etcdProviderOptionsAccessor.Value; _etcdClient = new EtcdClient(_etcdProviderOptions.ConnectionString, _etcdProviderOptions.Port, _etcdProviderOptions.Username, _etcdProviderOptions.Password, _etcdProviderOptions.CaCertificate, _etcdProviderOptions.ClientCertificate, _etcdProviderOptions.ClientKey, _etcdProviderOptions.IsPublicRootCa); if (!string.IsNullOrEmpty(_etcdProviderOptions.Username) && !string.IsNullOrEmpty(_etcdProviderOptions.Password)) { _metadata = new Metadata { { "Authorization", $"Basic {_etcdProviderOptions.Username}:{_etcdProviderOptions.Password}" } }; } }
/// <summary> /// 获取数据处理实例 /// </summary> /// <returns></returns> public static IDataProvider <T> GetInstance <T>(DataProviderType provider, IDataProviderOptions options) where T : class { IDataProvider <T> _repository = null; switch (provider) { case DataProviderType.MSSQL: _repository = new DataProvider <T>(options); break; //case DataProviderType.MYSQL: // _repository = new MySqlProvider<T>(); // break; default: break; } if (null == _repository) { throw new Exception("no data provider is matched"); } return(_repository); }
//public IDataProviderOptions DataProviderOptions { get; set; } #region ctor public DataRepositoryBase(IDataProviderOptions options) { //DataProviderOptions = options; _repository = new DataProvider <T>(options); }
public DataProvider(IDataProviderOptions options) { _providerOptions = options; ConnectionString = _providerOptions.ConnectionString; }
public DataRepository(IDataProviderOptions options) { DataProviderOptions = options; _repository = new DataProvider <TImpl>(options); }