Created
August 9, 2023 07:51
-
-
Save onyxmaster/7139baa4059cb2648d15d3be683d089f to your computer and use it in GitHub Desktop.
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
using MongoDB.Driver; | |
using MongoDB.Driver.Linq; | |
var filter = Builders<Document>.Filter.Gt(v => v.S, 1); | |
var settings = MongoClientSettings.FromConnectionString("mongodb://localhost:27017"); | |
foreach (var provider in Enum.GetValues<LinqProvider>()) | |
{ | |
settings.LinqProvider = provider; | |
Console.Write($"Provider {provider}: "); | |
try | |
{ | |
new MongoClient(settings) | |
.GetDatabase("test") | |
.GetCollection<Document>("test") | |
.Find(filter) | |
.FirstOrDefault(); | |
} | |
catch (Exception exception) | |
{ | |
Console.WriteLine(exception.Message); | |
continue; | |
} | |
Console.WriteLine("success"); | |
} | |
record struct UserType(int Value) | |
{ | |
public static implicit operator int(UserType self) => self.Value; | |
} | |
record Document(UserType S); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment