示例#1
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;
            }
        }
示例#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>
        /// <param name="objectInitialisationOptions"></param>
        public RelationalStore(
            Func <string> connectionString,
            string applicationName,
            ISqlCommandFactory sqlCommandFactory,
            RelationalMappings mappings,
            JsonSerializerSettings jsonSettings,
            IRelatedDocumentStore relatedDocumentStore,
            int keyBlockSize = 20,
            ObjectInitialisationOptions objectInitialisationOptions = ObjectInitialisationOptions.None)
        {
            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;
            this.objectInitialisationOptions = objectInitialisationOptions;
        }
示例#3
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
         )
 {
 }