Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an option to allow the user to opt-in for LINQ3 provider that actually causes regressions. See #4000
- Loading branch information
1 parent
047c51d
commit de3b27e
Showing
9 changed files
with
53 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/persistence/Elsa.Persistence.MongoDb/Services/ElsaMongoDbDriverHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Elsa.Persistence.MongoDb.Options; | ||
using MongoDB.Driver; | ||
using System; | ||
using System.Collections.Concurrent; | ||
|
||
namespace Elsa.Persistence.MongoDb.Services | ||
{ | ||
public static class ElsaMongoDbDriverHelpers | ||
{ | ||
/// <summary> | ||
/// Avoid creating too much instances for MongoClient. | ||
/// </summary> | ||
private static readonly ConcurrentDictionary<string, MongoClient> _clients = new(); | ||
|
||
public static MongoClient CreateClient(ElsaMongoDbOptions options) | ||
{ | ||
if (string.IsNullOrEmpty(options.ConnectionString)) throw new ArgumentException("Connection string is required.", nameof(options.ConnectionString)); | ||
if (!_clients.TryGetValue(options.ConnectionString, out MongoClient client)) | ||
{ | ||
var connectionString = options.ConnectionString; | ||
var clientSettings = MongoClientSettings.FromConnectionString(connectionString); | ||
if (options.UseNewLinq3Provider == false) | ||
{ | ||
clientSettings.LinqProvider = MongoDB.Driver.Linq.LinqProvider.V2; | ||
} | ||
client = new MongoClient(clientSettings); | ||
} | ||
|
||
return client; | ||
} | ||
} | ||
} |