Пример #1
0
        private void InitStore()
        {
            if (store != null)
            {
                return;
            }
            if (autoMigrations)
            {
                new Migrator(connectionString).Upgrade();
            }

            var jsonSettings = new JsonSerializerSettings
            {
                DateFormatHandling     = DateFormatHandling.IsoDateFormat,
                DateTimeZoneHandling   = DateTimeZoneHandling.RoundtripKind,
                TypeNameHandling       = TypeNameHandling.Auto,
                TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple,
            };

            var mappings = new RelationalMappings();

            mappings.Install(new[] { new StoredWorkFlowStateMap() });

            store = new RelationalStore(
                connectionString,
                appName,
                new SqlCommandFactory(),
                mappings,
                jsonSettings,
                new EmptyRelatedDocumentStore()
                );
        }
Пример #2
0
 void InitializeStore()
 {
     Mappings = new RelationalMappings();
     Mappings.Install(new List <DocumentMap>()
     {
         new CustomerMap(),
         new ProductMap(),
         new LineItemMap()
     });
     Store = BuildRelationalStore(TestDatabaseConnectionString, 0.01);
 }
Пример #3
0
        public OrderRepository(string connectionString)
        {
            Mappings = new RelationalMappings();
            Mappings.Install(new[] { new OrderMap() });

            Store = new RelationalStore(connectionString,
                                        "OrderService",
                                        new SqlCommandFactory(),
                                        Mappings,
                                        Settings,
                                        new EmptyRelatedDocumentStore());
        }
        public DataModificationQueryBuilderFixture()
        {
            var mappings = new RelationalMappings();

            mappings.Install(new DocumentMap[]
            {
                new TestDocumentMap(),
                new TestDocumentWithRelatedDocumentsMap(),
                new TestDocumentWithMultipleRelatedDocumentsMap(),
                new OtherMap()
            });
            builder = new DataModificationQueryBuilder(
                mappings,
                new JsonSerializerSettings()
                );
        }
Пример #5
0
        void InitializeStore()
        {
            Mappings = new RelationalMappings();

            Mappings.Install(new List <DocumentMap>()
            {
                new CustomerMap(),
                new CustomerToTestSerializationMap(),
                new BrandMap(),
                new BrandToTestSerializationMap(),
                new ProductMap <Product>(),
                new SpecialProductMap(),
                new ProductToTestSerializationMap(),
                new LineItemMap(),
                new MachineMap(),
                new MachineToTestSerializationMap()
            });
            Store = BuildRelationalStore(TestDatabaseConnectionString, 0.01);
        }
Пример #6
0
        /// <summary>
        /// Creates a new Relational Store
        /// </summary>
        /// <param name="connectionString">Allows the connection string to be set after the store is built (but before it is used)</param>
        /// <param name="applicationName">Name of the application in the SQL string</param>
        /// <param name="sqlCommandFactory"></param>
        /// <param name="mappings"></param>
        /// <param name="jsonSettings"></param>
        /// <param name="relatedDocumentStore">If you don't have releated documents use the EmptyRelatedDocumentStore</param>
        /// <param name="keyBlockSize">Block size for the KeyAllocator</param>
        public RelationalStore(
            Func <string> connectionString,
            string applicationName,
            ISqlCommandFactory sqlCommandFactory,
            RelationalMappings mappings,
            JsonSerializerSettings jsonSettings,
            IRelatedDocumentStore relatedDocumentStore,
            int keyBlockSize = 20)
        {
            this.registry = new Lazy <RelationalTransactionRegistry>(
                () => SetConnectionStringOptions(connectionString(), applicationName)
                );
            this.sqlCommandFactory = sqlCommandFactory;
            this.mappings          = mappings;
            keyAllocator           = new KeyAllocator(this, keyBlockSize);

            this.jsonSettings         = jsonSettings;
            this.relatedDocumentStore = relatedDocumentStore;
        }
Пример #7
0
 public RelationalStore(
     string connectionString,
     string applicationName,
     ISqlCommandFactory sqlCommandFactory,
     RelationalMappings mappings,
     JsonSerializerSettings jsonSettings,
     IRelatedDocumentStore relatedDocumentStore,
     int keyBlockSize = 20)
     : this(
         () => connectionString,
         applicationName,
         sqlCommandFactory,
         mappings,
         jsonSettings,
         relatedDocumentStore,
         keyBlockSize
         )
 {
 }
Пример #8
0
        public RelationalTransaction(
            RelationalTransactionRegistry registry,
            RetriableOperation retriableOperation,
            IsolationLevel isolationLevel,
            ISqlCommandFactory sqlCommandFactory,
            JsonSerializerSettings jsonSerializerSettings,
            RelationalMappings mappings,
            IKeyAllocator keyAllocator,
            IRelatedDocumentStore relatedDocumentStore,
            string name = null,
            ObjectInitialisationOptions objectInitialisationOptions = ObjectInitialisationOptions.None
            )
        {
            this.registry               = registry;
            this.retriableOperation     = retriableOperation;
            this.sqlCommandFactory      = sqlCommandFactory;
            this.jsonSerializerSettings = jsonSerializerSettings;
            this.mappings               = mappings;
            this.keyAllocator           = keyAllocator;
            this.relatedDocumentStore   = relatedDocumentStore;
            this.name = name ?? Thread.CurrentThread.Name;
            this.objectInitialisationOptions = objectInitialisationOptions;
            if (string.IsNullOrEmpty(name))
            {
                this.name = "<unknown>";
            }

            dataModificationQueryBuilder = new DataModificationQueryBuilder(mappings, jsonSerializerSettings);

            try
            {
                registry.Add(this);
                connection = new SqlConnection(registry.ConnectionString);
                connection.OpenWithRetry();
                transaction = connection.BeginTransaction(isolationLevel);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #9
0
 public RelationalStore(
     string connectionString,
     string applicationName,
     ISqlCommandFactory sqlCommandFactory,
     RelationalMappings mappings,
     JsonSerializerSettings jsonSettings,
     IRelatedDocumentStore relatedDocumentStore,
     int keyBlockSize = 20,
     ObjectInitialisationOptions objectInitialisationOptions = ObjectInitialisationOptions.None)
     : this(
         () => connectionString,
         applicationName,
         sqlCommandFactory,
         mappings,
         jsonSettings,
         relatedDocumentStore,
         keyBlockSize,
         objectInitialisationOptions
         )
 {
 }
Пример #10
0
 public BrandConverter(RelationalMappings relationalMappings) : base(relationalMappings)
 {
 }
Пример #11
0
 protected InheritedClassConverter(RelationalMappings relationalMappings = null) : base(relationalMappings)
 {
 }
Пример #12
0
 public ProductConverter(RelationalMappings relationalMappings) : base(relationalMappings)
 {
 }
Пример #13
0
 public DataModificationQueryBuilder(RelationalMappings mappings, JsonSerializerSettings jsonSerializerSettings)
 {
     this.mappings = mappings;
     this.jsonSerializerSettings = jsonSerializerSettings;
 }
Пример #14
0
 public ProjectionMapper(IDataReader reader, JsonSerializerSettings jsonSerializerSettings, RelationalMappings mappings)
 {
     this.mappings = mappings;
     this.reader   = reader;
     this.jsonSerializerSettings = jsonSerializerSettings;
 }
 public RelationalJsonContractResolver(RelationalMappings mappings)
 {
     this.mappings = mappings;
 }
Пример #16
0
 protected InheritedClassConverterBase(RelationalMappings relationalMappings = null)
 {
     RelationalMappings = relationalMappings;
 }