From 9c2c455353bae0c2f964ead057a60f283dbeb37d Mon Sep 17 00:00:00 2001 From: Sergey Akopov Date: Mon, 19 Mar 2018 08:46:39 -0600 Subject: [PATCH] Update Dapper reference to tesolve #2. --- .gitignore | 1 + .../AmbientDbContext.ProxyAsync.cs | 145 ++++++++++++++++++ .../Dapper.AmbientContext.csproj | 4 +- .../Storage/AsyncLocalContextStorage.cs | 2 +- .../Storage/ContextualStorageHelper.cs | 16 +- .../Storage/LogicalCallContextStorage.cs | 2 +- .../AmbientDbContextFactoryTests.cs | 4 +- .../AmbientDbContextLocatorTests.cs | 6 +- .../AmbientDbContextStorageProviderTests.cs | 2 +- .../AmbientDbContextTests.cs | 40 ++--- .../ContextualStorageHelperTests.cs | 12 +- .../Dapper.AmbientContext.Tests.csproj | 10 +- .../LogicalCallContextStorageTests.cs | 8 +- 13 files changed, 203 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 7964536..32e1eac 100644 --- a/.gitignore +++ b/.gitignore @@ -159,6 +159,7 @@ ClientBin/ *.pfx *.publishsettings node_modules/ +.vs/ # RIA/Silverlight projects Generated_Code/ diff --git a/src/Dapper.AmbientContext/AmbientDbContext.ProxyAsync.cs b/src/Dapper.AmbientContext/AmbientDbContext.ProxyAsync.cs index 2124748..e404773 100644 --- a/src/Dapper.AmbientContext/AmbientDbContext.ProxyAsync.cs +++ b/src/Dapper.AmbientContext/AmbientDbContext.ProxyAsync.cs @@ -381,6 +381,37 @@ public async Task QuerySingleOrDefaultAsync(CommandDefinition command) .ConfigureAwait(false); } + /// + /// Execute a single-row query asynchronously using .NET 4.5 + /// . + /// + /// + /// The SQL statement to execute. + /// + /// + /// The SQL query parameters. + /// + /// + /// The number of seconds before command execution timeout. + /// + /// + /// Determines whether the command is a stored procedure or a batch. + /// + /// + /// A task representing the asynchronous operation. + /// + public async Task QueryFirstOrDefaultAsync( + string sql, + object param = null, + int? commandTimeout = null, + CommandType? commandType = null) + { + await PrepareConnectionAndTransactionAsync(default(CancellationToken)).ConfigureAwait(false); + + return await Connection.QueryFirstOrDefaultAsync(sql, param, Transaction, commandTimeout, commandType) + .ConfigureAwait(false); + } + /// /// Execute a single-row query asynchronously using .NET 4.5 /// . @@ -415,6 +446,37 @@ public async Task QuerySingleOrDefaultAsync(CommandDefinition command) .ConfigureAwait(false); } + /// + /// Execute a single-row query asynchronously using .NET 4.5 + /// . + /// + /// + /// The SQL statement to execute. + /// + /// + /// The SQL query parameters. + /// + /// + /// The number of seconds before command execution timeout. + /// + /// + /// Determines whether the command is a stored procedure or a batch. + /// + /// + /// A task representing the asynchronous operation. + /// + public async Task QuerySingleAsync( + string sql, + object param = null, + int? commandTimeout = null, + CommandType? commandType = null) + { + await PrepareConnectionAndTransactionAsync(default(CancellationToken)).ConfigureAwait(false); + + return await Connection.QuerySingleAsync(sql, param, Transaction, commandTimeout, commandType) + .ConfigureAwait(false); + } + /// /// Execute a single-row query asynchronously using .NET 4.5 /// . @@ -449,6 +511,89 @@ public async Task QuerySingleOrDefaultAsync(CommandDefinition command) .ConfigureAwait(false); } + /// + /// Execute a single-row query asynchronously using .NET 4.5 + /// . + /// + /// + /// The return type. + /// + /// + /// The SQL command definition. + /// + /// + /// A task representing the asynchronous operation. + /// + public async Task QuerySingleOrDefaultAsync(CommandDefinition command) + { + await PrepareConnectionAndTransactionAsync(default(CancellationToken)).ConfigureAwait(false); + + return await Connection.QuerySingleOrDefaultAsync(command) + .ConfigureAwait(false); + } + + /// + /// Execute a single-row query asynchronously using .NET 4.5 + /// . + /// + /// + /// The SQL statement to execute. + /// + /// + /// The SQL query parameters. + /// + /// + /// The number of seconds before command execution timeout. + /// + /// + /// Determines whether the command is a stored procedure or a batch. + /// + /// + /// A task representing the asynchronous operation. + /// + public async Task QuerySingleOrDefaultAsync( + string sql, + object param = null, + int? commandTimeout = null, + CommandType? commandType = null) + { + await PrepareConnectionAndTransactionAsync(default(CancellationToken)).ConfigureAwait(false); + + return await Connection.QuerySingleOrDefaultAsync(sql, param, Transaction, commandTimeout, commandType) + .ConfigureAwait(false); + } + + /// + /// Execute a single-row query asynchronously using .NET 4.5 + /// . + /// + /// + /// The SQL statement to execute. + /// + /// + /// The SQL query parameters. + /// + /// + /// The number of seconds before command execution timeout. + /// + /// + /// Determines whether the command is a stored procedure or a batch. + /// + /// + /// A task representing the asynchronous operation. + /// + public async Task QueryFirstAsync( + string sql, + object param = null, + int? commandTimeout = null, + CommandType? commandType = null) + { + await PrepareConnectionAndTransactionAsync(default(CancellationToken)).ConfigureAwait(false); + + return await Connection.QueryFirstAsync(sql, param, Transaction, commandTimeout, commandType) + .ConfigureAwait(false); + } + /// /// Execute a query asynchronously using .NET 4.5 /// . diff --git a/src/Dapper.AmbientContext/Dapper.AmbientContext.csproj b/src/Dapper.AmbientContext/Dapper.AmbientContext.csproj index 421db66..7d32643 100644 --- a/src/Dapper.AmbientContext/Dapper.AmbientContext.csproj +++ b/src/Dapper.AmbientContext/Dapper.AmbientContext.csproj @@ -5,7 +5,7 @@ Copyright Sergey Akopov 1.4.0 Sergey Akopov - net45;netstandard1.3 + net451;netstandard1.3;netstandard2.0 Dapper.AmbientContext Dapper.AmbientContext dapper;ambient;context @@ -21,7 +21,7 @@ - + diff --git a/src/Dapper.AmbientContext/Storage/AsyncLocalContextStorage.cs b/src/Dapper.AmbientContext/Storage/AsyncLocalContextStorage.cs index 313456d..dd825e3 100644 --- a/src/Dapper.AmbientContext/Storage/AsyncLocalContextStorage.cs +++ b/src/Dapper.AmbientContext/Storage/AsyncLocalContextStorage.cs @@ -1,4 +1,4 @@ -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 // -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) 2016 Sergey Akopov diff --git a/src/Dapper.AmbientContext/Storage/ContextualStorageHelper.cs b/src/Dapper.AmbientContext/Storage/ContextualStorageHelper.cs index 8ee7bb6..51c888d 100644 --- a/src/Dapper.AmbientContext/Storage/ContextualStorageHelper.cs +++ b/src/Dapper.AmbientContext/Storage/ContextualStorageHelper.cs @@ -78,7 +78,7 @@ public ContextualStorageHelper(IContextualStorage storage) /// public IImmutableStack GetStack() { -#if NET45 +#if NET451 var crossReferenceKey = _storage.GetValue(AmbientDbContextStorageKey.Key); #else var crossReferenceKey = _storage.GetValue(AmbientDbContextStorageKey.Key); @@ -92,7 +92,7 @@ public IImmutableStack GetStack() IImmutableStack value; -#if NET45 +#if NET451 AmbientDbContextTable.TryGetValue(crossReferenceKey.Value, out value); #else AmbientDbContextTable.TryGetValue(crossReferenceKey, out value); @@ -108,7 +108,7 @@ public IImmutableStack GetStack() /// public void SaveStack(IImmutableStack stack) { -#if NET45 +#if NET451 var crossReferenceKey = _storage.GetValue(AmbientDbContextStorageKey.Key); #else var crossReferenceKey = _storage.GetValue(AmbientDbContextStorageKey.Key); @@ -123,7 +123,7 @@ public void SaveStack(IImmutableStack stack) IImmutableStack value; // Drop the existing key and recreate because the value is immutable -#if NET45 +#if NET451 if (AmbientDbContextTable.TryGetValue(crossReferenceKey.Value, out value)) { AmbientDbContextTable.Remove(crossReferenceKey.Value); @@ -146,7 +146,7 @@ public void SaveStack(IImmutableStack stack) /// private void Initialize() { -#if NET45 +#if NET451 var crossReferenceKey = _storage.GetValue(AmbientDbContextStorageKey.Key); #else var crossReferenceKey = _storage.GetValue(AmbientDbContextStorageKey.Key); @@ -154,14 +154,14 @@ private void Initialize() if (crossReferenceKey == null) { -#if NET45 +#if NET451 crossReferenceKey = new ContextualStorageItem(Guid.NewGuid().ToString("N")); #else crossReferenceKey = Guid.NewGuid().ToString("N"); #endif _storage.SetValue(AmbientDbContextStorageKey.Key, crossReferenceKey); -#if NET45 +#if NET451 AmbientDbContextTable.Add(crossReferenceKey.Value, ImmutableStack.Create()); #else AmbientDbContextTable.Add(crossReferenceKey, ImmutableStack.Create()); @@ -169,7 +169,7 @@ private void Initialize() } } -#if NET45 +#if NET451 /// /// Wraps values in storage to enable access across AppDomains. While all storage /// mechanisms will use the same approach, it is only required for the Logical diff --git a/src/Dapper.AmbientContext/Storage/LogicalCallContextStorage.cs b/src/Dapper.AmbientContext/Storage/LogicalCallContextStorage.cs index 74ff908..1ffefb5 100644 --- a/src/Dapper.AmbientContext/Storage/LogicalCallContextStorage.cs +++ b/src/Dapper.AmbientContext/Storage/LogicalCallContextStorage.cs @@ -24,7 +24,7 @@ // Represents the type that implements storage on top of logical call context. // // -------------------------------------------------------------------------------------------------------------------- -#if NET45 +#if NET451 namespace Dapper.AmbientContext.Storage { using System.Runtime.Remoting.Messaging; diff --git a/test/Dapper.AmbientContext.Tests/AmbientDbContextFactoryTests.cs b/test/Dapper.AmbientContext.Tests/AmbientDbContextFactoryTests.cs index eb397e8..25ac88c 100644 --- a/test/Dapper.AmbientContext.Tests/AmbientDbContextFactoryTests.cs +++ b/test/Dapper.AmbientContext.Tests/AmbientDbContextFactoryTests.cs @@ -14,7 +14,7 @@ class When_calling_create_with_none_closed_database_connection { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -56,7 +56,7 @@ class When_calling_create_with_closed_database_connection { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); diff --git a/test/Dapper.AmbientContext.Tests/AmbientDbContextLocatorTests.cs b/test/Dapper.AmbientContext.Tests/AmbientDbContextLocatorTests.cs index c428833..1a112a7 100644 --- a/test/Dapper.AmbientContext.Tests/AmbientDbContextLocatorTests.cs +++ b/test/Dapper.AmbientContext.Tests/AmbientDbContextLocatorTests.cs @@ -14,7 +14,7 @@ class When_ambient_database_context_stack_is_empty { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -48,7 +48,7 @@ class When_ambient_database_context_stack_has_one_ambient_database_context { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -89,7 +89,7 @@ class When_ambient_database_context_stack_has_more_than_one_ambient_database_con { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); diff --git a/test/Dapper.AmbientContext.Tests/AmbientDbContextStorageProviderTests.cs b/test/Dapper.AmbientContext.Tests/AmbientDbContextStorageProviderTests.cs index 9bc654f..eeff9ff 100644 --- a/test/Dapper.AmbientContext.Tests/AmbientDbContextStorageProviderTests.cs +++ b/test/Dapper.AmbientContext.Tests/AmbientDbContextStorageProviderTests.cs @@ -28,7 +28,7 @@ class When_getting_storage_after_it_has_been_set { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); diff --git a/test/Dapper.AmbientContext.Tests/AmbientDbContextTests.cs b/test/Dapper.AmbientContext.Tests/AmbientDbContextTests.cs index 1292c95..d41466d 100644 --- a/test/Dapper.AmbientContext.Tests/AmbientDbContextTests.cs +++ b/test/Dapper.AmbientContext.Tests/AmbientDbContextTests.cs @@ -16,7 +16,7 @@ class When_creating_first_ambient_database_context_with_transaction_suppression_ { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -69,7 +69,7 @@ class When_creating_multiple_joined_ambient_database_contexts_with_transaction_s { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -131,7 +131,7 @@ class When_creating_disjoined_ambient_database_contexts_with_transaction_suppres { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -194,7 +194,7 @@ class When_disposing_single_ambient_database_context { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -252,7 +252,7 @@ class When_disposing_single_ambient_database_context_without_explicit_commit { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -328,7 +328,7 @@ class When_disposing_multiple_joined_ambient_database_contexts { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -408,7 +408,7 @@ class When_disposing_multiple_disjoined_ambient_database_contexts { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -488,7 +488,7 @@ class When_disposing_multiple_joined_ambient_database_contexts_out_of_order { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -582,7 +582,7 @@ class When_committing_single_ambient_database_context_without_suppressed_transac { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -650,7 +650,7 @@ class When_committing_single_ambient_database_context_without_suppressed_transac { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -711,7 +711,7 @@ class When_committing_single_ambient_database_context_with_suppressed_transactio { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -767,7 +767,7 @@ class When_committing_joined_child_ambient_database_context { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -834,7 +834,7 @@ class When_committing_joined_parent_ambient_database_context { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -902,7 +902,7 @@ class When_the_joined_parent_ambient_database_context_requests_connection_first { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -964,7 +964,7 @@ class When_the_joined_child_ambient_database_context_requests_connection_first { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -1030,7 +1030,7 @@ class When_rolling_back_single_ambient_database_context_without_suppressed_trans { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -1091,7 +1091,7 @@ class When_rolling_back_single_ambient_database_context_with_suppressed_transact { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -1147,7 +1147,7 @@ class When_rolling_back_joined_child_ambient_database_context { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -1214,7 +1214,7 @@ class When_rolling_back_joined_parent_ambient_database_context { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -1282,7 +1282,7 @@ class When_rolling_back_single_ambient_database_context_without_suppressed_trans { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); diff --git a/test/Dapper.AmbientContext.Tests/ContextualStorageHelperTests.cs b/test/Dapper.AmbientContext.Tests/ContextualStorageHelperTests.cs index d39cf64..06da2ba 100644 --- a/test/Dapper.AmbientContext.Tests/ContextualStorageHelperTests.cs +++ b/test/Dapper.AmbientContext.Tests/ContextualStorageHelperTests.cs @@ -14,7 +14,7 @@ class When_initializing_contextual_storage_helper { Establish context = () => { -#if NET45 +#if NET451 _storage = new LogicalCallContextStorage(); #else _storage = new AsyncLocalContextStorage(); @@ -50,7 +50,7 @@ class When_getting_an_empty_ambient_database_context_stack_from_the_contextual_s { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); @@ -84,13 +84,16 @@ class When_getting_non_empty_ambient_database_context_stack_from_the_contextual_ { Establish context = () => { -#if NET45 +#if NET451 AmbientDbContextStorageProvider.SetStorage(new LogicalCallContextStorage()); #else AmbientDbContextStorageProvider.SetStorage(new AsyncLocalContextStorage()); #endif - _expectedAmbientDbContext = new Mock().Object; + _dbConnectionMock = new Mock(); + _dbConnectionMock.Setup(mock => mock.State).Returns(() => ConnectionState.Closed); + + _expectedAmbientDbContext = new AmbientDbContext(_dbConnectionMock.Object, true, true, IsolationLevel.ReadCommitted); _contextualStorageHelper = new ContextualStorageHelper(AmbientDbContextStorageProvider.Storage); @@ -119,6 +122,7 @@ class When_getting_non_empty_ambient_database_context_stack_from_the_contextual_ AmbientDbContextStorageProvider.SetStorage(null); }; + private static Mock _dbConnectionMock; private static IAmbientDbContext _expectedAmbientDbContext; private static IImmutableStack _returnedAmbientDbContextStack; private static ContextualStorageHelper _contextualStorageHelper; diff --git a/test/Dapper.AmbientContext.Tests/Dapper.AmbientContext.Tests.csproj b/test/Dapper.AmbientContext.Tests/Dapper.AmbientContext.Tests.csproj index 694cc11..fd45022 100644 --- a/test/Dapper.AmbientContext.Tests/Dapper.AmbientContext.Tests.csproj +++ b/test/Dapper.AmbientContext.Tests/Dapper.AmbientContext.Tests.csproj @@ -1,15 +1,19 @@  - net45;netcoreapp1.1 + net451;netcoreapp1.1;netcoreapp2.0 + + + + Full - - + + diff --git a/test/Dapper.AmbientContext.Tests/LogicalCallContextStorageTests.cs b/test/Dapper.AmbientContext.Tests/LogicalCallContextStorageTests.cs index 09ca9a3..e853a5c 100644 --- a/test/Dapper.AmbientContext.Tests/LogicalCallContextStorageTests.cs +++ b/test/Dapper.AmbientContext.Tests/LogicalCallContextStorageTests.cs @@ -10,7 +10,7 @@ class When_getting_existing_item_from_logical_callcontext_storage { Establish context = () => { -#if NET45 +#if NET451 _storage = new LogicalCallContextStorage(); #else _storage = new AsyncLocalContextStorage(); @@ -43,7 +43,7 @@ class When_getting_inexisting_item_from_logical_callcontext_storage { Establish context = () => { -#if NET45 +#if NET451 _storage = new LogicalCallContextStorage(); #else _storage = new AsyncLocalContextStorage(); @@ -69,7 +69,7 @@ class When_checking_if_added_item_exists_in_the_logical_callcontext_storage { Establish context = () => { -#if NET45 +#if NET451 _storage = new LogicalCallContextStorage(); #else _storage = new AsyncLocalContextStorage(); @@ -102,7 +102,7 @@ class When_removing_an_item_from_the_logical_callcontext_storage { Establish context = () => { -#if NET45 +#if NET451 _storage = new LogicalCallContextStorage(); #else _storage = new AsyncLocalContextStorage();