public DapperSessionFactory(IDapperConfiguration configuration, ILogger <DapperSessionFactory> logger, IConnectionStringProvider connectionStringProvider)
 {
     _connectionStringProvider = connectionStringProvider;
     _configuration            = configuration;
     _logger         = logger;
     _loadedContexts = new Lazy <ConcurrentDictionary <Type, string> >(() => GetAllLoadedContexts());
 }
 public DapperRepositoryBase(IDapperConfiguration configuration)
 {
     Configurationn  = configuration;
     WriteConnection = new MySqlConnection(Configurationn.WriteConnectionString);
     ReadConnection  = new MySqlConnection(Configurationn.ReadConnectionString);
     Connection      = new DapperConnection(WriteConnection, ReadConnection);
 }
 private DapperConfiguration()
 {
     ContainerCustomisations = new ContainerCustomisations();
     Providers  = new Dictionary <string, IConnectionStringProvider>();
     Assemblies = new List <Assembly>();
     DefaultConnectionStringName = "__Default";
     Instance = null;
 }
 public DapperRepositoryBase(IDapperConfiguration configuration, bool IsOriginalTableName)
 {
     Configurationn  = configuration;
     WriteConnection = new MySqlConnection(Configurationn.WriteConnectionString);
     ReadConnection  = new MySqlConnection(Configurationn.ReadConnectionString);
     SqlMapperExtensions.IsOriginalTableName = IsOriginalTableName;
     Connection = new DapperConnection(WriteConnection, ReadConnection);
 }
示例#5
0
 public DapperSessionContext(IDapperSessionFactory factory, IDapperConfiguration configuration, ILogger <DapperSessionContext> logger)
 {
     _factory       = factory;
     _logger        = logger;
     _configuration = configuration;
     IsolationLevel = IsolationLevel.ReadCommitted;
     _sessionMap    = new Lazy <ConcurrentDictionary <string, IDapperSession> >(() => new ConcurrentDictionary <string, IDapperSession>());
 }
示例#6
0
        /// <summary>
        ///     Creates a new session factory.
        /// </summary>
        /// <param name="conString">The connection string to the sql server database.</param>
        /// <param name="configuration">The dapper configuration to use.</param>
        public SessionFactory(string conString, IDapperConfiguration configuration)
        {
            Guard.ArgumentNotNull(configuration, nameof(configuration));
            Guard.ArgumentNotNullOrEmptyOrWhiteSpace(conString, nameof(conString));

            _conString    = conString;
            Configuration = configuration;
        }
示例#7
0
        internal Session(SqlConnection connection, IDapperConfiguration config)
        {
            _connection = connection;

            // TODO: durable open
            _connection.Open();

            Configuration = config;
        }
示例#8
0
        /// <summary>
        /// 获取Sql生成器
        /// </summary>
        /// <returns></returns>
        public ISqlGenerator GetSqlGenerator()
        {
            if (_config == null)
            {
                _config = new DapperConfiguration(_mappingAssemblies, _dialect);
            }

            var sqlGeneratorImpl = new SqlGeneratorImpl(_config);

            return(sqlGeneratorImpl);
        }
        protected virtual IClassMapper GetClassMapper(Type type, IDapperConfiguration configuration)
        {
            var map = configuration.GetMap(type);

            if (map == null)
            {
                throw new NullReferenceException(string.Format("Map was not found for {0}", type));
            }

            return(map);
        }
        public void Build()
        {
            if (Dialect == null)
            {
                throw new NullReferenceException("SqlDialect has not been set. Call UseSqlDialect().");
            }

            if (Providers.Any() == false)
            {
                UsingConnectionProvider <StaticConnectionStringProvider>(DefaultConnectionStringName);
            }

            _container.Build(this);
            Instance = this;
        }
示例#11
0
        static UnitOfWorkManagesTransactionsStoryBase()
        {
            // can only be configured once per entity
            _config = DapperConfiguration
                      .Use()
                      .UseSqlDialect(new SqlServerDialect());

            var classMapper = new CustomEntityMap <TestEntity>();

            classMapper.SetIdentityGenerated(m => m.Id);

            var classMappers = new List <IClassMapper>
            {
                classMapper
            };

            classMappers.Each(n => _config.Register(n));
        }
示例#12
0
        protected void AndGivenADapperConfiguration()
        {
            // instance be application scope
            _config = DapperConfiguration
                      .Use()
                      .UseSqlDialect(new SqlServerDialect());

            var classMapper = new CustomEntityMap <MyEntity>();

            classMapper.SetIdentityGenerated(m => m.Id);

            var classMappers = new List <IClassMapper>
            {
                classMapper
            };

            classMappers.Each(n => _config.Register(n));
        }
示例#13
0
 public TestRepository(IDapperConfiguration configuration) : base(configuration)
 {
 }
示例#14
0
 public PeopleReporitory(IDapperConfiguration configuration)
     : base(configuration)
 {
 }
示例#15
0
 public AddressInfoRepository(IDapperConfiguration configuration) : base(configuration, true)
 {
 }
示例#16
0
 public Repository(IDapperConfiguration configuration)
 {
     ConnectionString = configuration?.ConnectionString;
     Context          = new EFContext(ConnectionString);
 }
 public SqlGeneratorImpl(IDapperConfiguration configuration, ILogger <SqlGeneratorImpl> logger)
 {
     _logger       = logger;
     Configuration = configuration;
 }
示例#18
0
 public UsersRepository(IDapperConfiguration configuration) : base(configuration, true)
 {
 }
示例#19
0
 public RepositoryBase(IDapperConfiguration configuration)
 {
     Configuration   = configuration;
     WriteConnection = new MySqlConnection(configuration.WriteConnectionString);
     ReadConnection  = new MySqlConnection(configuration.ReadConnectionStrign);
 }
示例#20
0
 public static IDapperConfiguration UseMapper <TMapper>(this IDapperConfiguration configuration)
     where TMapper : IEntityMapper =>
 configuration.UseMapper(typeof(TMapper));
示例#21
0
 public MachineryInfoRepository(IDapperConfiguration configuration) : base(configuration, true)
 {
 }
示例#22
0
 public UserRepository(IDapperConfiguration configuration) : base(configuration)
 {
 }
 public ImportRepository(IDapperConfiguration configuration) : base(configuration, true)
 {
 }
 public BasicConfigurationRepository(IDapperConfiguration configuration) : base(configuration, true)
 {
 }
示例#25
0
 public AccountInfoRepositories(IDapperConfiguration configuration) : base(configuration)
 {
 }
示例#26
0
 public ShoppingRepository(IDapperConfiguration configuration) : base(configuration, true)
 {
 }
示例#27
0
 public SqlGeneratorImpl(IDapperConfiguration configuration)
 {
     Configuration = configuration;
 }
 public SqlGeneratorImpl(IDapperConfiguration configuration)
 {
     Configuration = configuration;
 }
示例#29
0
 public StaticConnectionStringProvider(IDapperConfiguration dapperConfiguration)
 {
     _dapperConfiguration = dapperConfiguration;
 }
示例#30
0
 public MaintenanceInfoRepository(IDapperConfiguration configuration) : base(configuration, true)
 {
 }