Example #1
0
 public WriteTransaction(
     RelationalTransactionRegistry registry,
     RetriableOperation operationsToRetry,
     IRelationalStoreConfiguration configuration,
     IKeyAllocator keyAllocator,
     string name = null
     ) : base(registry, operationsToRetry, configuration, name)
 {
     this.configuration = configuration;
     this.keyAllocator  = keyAllocator;
     builder            = new DataModificationQueryBuilder(configuration, AllocateId);
 }
Example #2
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;
        }
Example #3
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;
            }
        }