Exemplo n.º 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()
                );
        }
Exemplo n.º 2
0
 void InitializeStore()
 {
     Mappings = new RelationalMappings();
     Mappings.Install(new List <DocumentMap>()
     {
         new CustomerMap(),
         new ProductMap(),
         new LineItemMap()
     });
     Store = BuildRelationalStore(TestDatabaseConnectionString, 0.01);
 }
Exemplo n.º 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()
                );
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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
         )
 {
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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
         )
 {
 }
Exemplo n.º 10
0
 public BrandConverter(RelationalMappings relationalMappings) : base(relationalMappings)
 {
 }
Exemplo n.º 11
0
 protected InheritedClassConverter(RelationalMappings relationalMappings = null) : base(relationalMappings)
 {
 }
Exemplo n.º 12
0
 public ProductConverter(RelationalMappings relationalMappings) : base(relationalMappings)
 {
 }
Exemplo n.º 13
0
 public DataModificationQueryBuilder(RelationalMappings mappings, JsonSerializerSettings jsonSerializerSettings)
 {
     this.mappings = mappings;
     this.jsonSerializerSettings = jsonSerializerSettings;
 }
Exemplo n.º 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;
 }
Exemplo n.º 16
0
 protected InheritedClassConverterBase(RelationalMappings relationalMappings = null)
 {
     RelationalMappings = relationalMappings;
 }